Error numpy.ndarray size changed, may indicate binary incompatibility, Tutorial part 2

This situtation can arise when you do non-default installations and update packages. From your error, it seems you have an installed version of Brian, and one in the directory where you run the code (brian2/synapses/...). Concretely, if I’m not mistaken, at some point our Cython implementation of the SpikeQueue mechanism was compiled (which happens automatically when you run pip install for example), and at a later point numpy was downgraded so that is no longer binary-compatible with the numpy version that was in place when the SpikeQueue was compiled. When we ship compiled packages (with conda, or in the upcoming version with wheels), we handle this by compiling against the oldest supported version, which is forward-compatible with all newer versions.
Long story short, the easiest solution would be probably to remove your Brian2 installation and install it again, or to upgrade numpy to a version at least as new as the one when you installed Brian2 originally. If you prefer a less “brute-force” solution and want to use locally downloaded Brian2 sources, running python setup.by build_ext --inplace in the Brian2 source directory should probably fix the issue as well.

1 Like