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

**URL:** <https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400>\
**Category:** Support\
**Created:** [5 June 2021 05:44 UTC](https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400 "2021-06-05T05:44:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ziaeemehr](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/ziaeemehr/32/12_2.png) [@Ziaeemehr](https://brian.discourse.group/u/Ziaeemehr)\
**Post date:** [5 June 2021 05:44 UTC](https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400/1 "2021-06-05T05:44:38Z")

</div>

Hi and wish everybody being healthy.  
Why I get error runnign an example from Tutorial part 2 synapse:

```python
from brian2 import *
start_scope()

eqs = '''
dv/dt = (I-v)/tau : 1
I : 1
tau : second
'''
G = NeuronGroup(2, eqs, threshold='v>1', reset='v = 0', method='exact')
G.I = [2, 0]
G.tau = [10, 100]*ms

# Comment these two lines out to see what happens without Synapses
S = Synapses(G, G, on_pre='v_post += 0.2')
S.connect(i=0, j=1)

M = StateMonitor(G, 'v', record=True)

run(100*ms)

```

```auto
File "t1.py", line 14, in <module>
    S = Synapses(G, G, on_pre='v_post += 0.2')
  File "/home/ziaee/.local/lib/python3.8/site-packages/brian2/synapses/synapses.py", line 856, in __init__
    self._add_updater(argument, prepost, delay=pathway_delay,
  File "/home/ziaee/.local/lib/python3.8/site-packages/brian2/synapses/synapses.py", line 1032, in _add_updater
    updater = SynapticPathway(self, code, prepost, objname,
  File "/home/ziaee/.local/lib/python3.8/site-packages/brian2/synapses/synapses.py", line 271, in __init__
    self.queue = get_device().spike_queue(self.source.start, self.source.stop)
  File "/home/ziaee/.local/lib/python3.8/site-packages/brian2/devices/device.py", line 498, in spike_queue
    from brian2.synapses.cythonspikequeue import SpikeQueue
  File "brian2/synapses/cythonspikequeue.pyx", line 1, in init brian2.synapses.cythonspikequeue
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

```

I am using brian ‘2.4.2’.

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [7 June 2021 09:18 UTC](https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400/2 "2021-06-07T09:18:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rub](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/rub/32/744_2.png) [@Rub](https://brian.discourse.group/u/Rub)\
**Post date:** [1 July 2024 11:23 UTC](https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400/3 "2024-07-01T11:23:54Z")

</div>

For numpy 2.0

> <https://stackoverflow.com/questions/78650222/valueerror-numpy-dtype-size-changed-may-indicate-binary-incompatibility-expec>

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [1 July 2024 11:27 UTC](https://brian.discourse.group/t/error-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-tutorial-part-2/400/4 "2024-07-01T11:27:49Z")

</div>

> [@Rub](#):
>
> For numpy 2.0

Just for clarification : The latest Brian versions (since 2.7.0) are compatible with numpy 2.0, and pandas is compatible since version 2.2.0 as well. The linked stackoverflow uses an earlier pandas version that wasn’t yet compatible. Using the latest versions of all libraries should work, so make sure to upgrade the packages that depend on numpy as well, when you update numpy to 2.0.
