# Python bindings: ValueError: numpy.ndarray size changed

**URL:** <https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685>\
**Category:** Installing preCICE\
**Tags:** python, ubuntu\
**Created:** [August 9, 2021, 2:15pm UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685 "2021-08-09T14:15:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arslansadiq](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/arslansadiq/32/849_2.png) [@arslansadiq](https://precice.discourse.group/u/arslansadiq)\
**Post date:** [August 9, 2021, 2:15pm UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/1 "2021-08-09T14:15:47Z")

</div>

I am trying to get the python binding for precice running and upon installing I am getting ValueError (described below). I previously had anaconda installed and using its python3.8.10 and libprecice2.2.0 but now I have removed anaconda and updated precice and still I am facing similar issue.

- preCICE version: libprecice2\_2.2.1
- Operating system or platform (e.g. “Ubuntu 20.04”)
- Installation method: apt, pip3
- Dependency versions: python3.8.10, numpy1.17.4

```plaintext
pip3 install --user pyprecice
Processing /home/mansari/.cache/pip/wheels/53/96/9c/871e18d16d08e5d3a1eedaf5bbe74d115291e44c67c7379f70/pyprecice-2.2.1.1-py2.py3-none-any.whl
Requirement already satisfied: mpi4py in /home/mansari/.local/lib/python3.8/site-packages (from pyprecice) (3.0.3)
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from pyprecice) (1.17.4)
ERROR: fenicsprecice 1.1.0+10.gb248cf0 requires scipy, which is not installed.
Installing collected packages: pyprecice
Successfully installed pyprecice-2.2.1.1

********** $ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import precice
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mansari/.local/lib/python3.8/site-packages/precice/ __init__.py", line 4, in <module>
    from cyprecice import Interface, action_read_iteration_checkpoint, action_write_iteration_checkpoint, action_write_initial_data, get_version_information
  File "cyprecice/cyprecice.pyx", line 1, in init cyprecice
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

```

**Note:**  
After upgrading the numpy version to 1.20 (same python version) it started working. Is this an issue with the bindings or did I do something wrong before?

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [August 9, 2021, 2:19pm UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/2 "2021-08-09T14:19:14Z")

</div>

I tried downgrading my NumPy to 1.7.4, but the installation keeps working, so maybe this is not the issue.

(FYI, I was talking with @arslansadiq when opening this thread)

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [August 9, 2021, 3:49pm UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/3 "2021-08-09T15:49:58Z")

</div>

I just tried on my machine with Ubuntu 20.04 and NumPy 1.17.4 and it worked without problems. Did you try to install SciPy to see if this makes a difference? I am curious since there is an error about the SciPy dependency. Which version of pip are you using? I am currently at 21.2.2.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [August 10, 2021, 7:23am UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/4 "2021-08-10T07:23:53Z")

</div>

Hi @arslansadiq

The following line is indeed puzzling, because it is in fact it is pointing to an error from the package `fenicsprecice` which is not even what you are installing here.

> [@arslansadiq](#):
>
> `ERROR: fenicsprecice 1.1.0+10.gb248cf0 requires scipy, which is not installed.`

By chance do you have `fenicsprecice` also installed? And as @ajaust mentioned have you installed scipy?

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [August 10, 2021, 7:34am UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/5 "2021-08-10T07:34:41Z")

</div>

For testing I removed scipy (`python3-scipy`) from my machine and it still works.

```
> pip install --user pyprecice
Collecting pyprecice
  Using cached pyprecice-2.2.1.1-py2.py3-none-any.whl
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from pyprecice) (1.17.4)
Requirement already satisfied: mpi4py in /usr/lib/python3/dist-packages (from pyprecice) (3.0.3)
Installing collected packages: pyprecice
Successfully installed pyprecice-2.2.1.1

```

It both worked with versions 21.2.3 and 21.2.2 of `pip` for me.

Maybe you could tell us which version of pip you use with `pip --version `.

Besides that I could see that this error is still a side effect of your Conda installation. Are there any Conda leftovers on the system? Maybe some paths are still set? Did you open a new terminal after removing Conda and did you clean up your `.bashrc` or `.bash_profile`? Conda normally offers to add some environment variables in one of these files.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [August 23, 2022, 8:17am UTC](https://precice.discourse.group/t/python-bindings-valueerror-numpy-ndarray-size-changed/685/6 "2022-08-23T08:17:47Z")

</div>

Closed on August 23, 2022, 8:17am UTC


