0

When executing a script using pandas I get this error:

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Which I've gleaned from this thread is because it's calling a too recent version of numpy, and i need to install an earlier version.

The github repo I'm running the script from references numpy 1.5.2 so I ran:

pip install numpy==1.5.2

which results in this output:

ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement numpy==1.5.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0, 1.25.1, 1.25.2, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 2.0.0, 2.0.1, 2.0.2, 2.1.0rc1, 2.1.0, 2.1.1)
ERROR: No matching distribution found for numpy==1.5.2

So, I selected 1.6.0 from that list and ran pip install numpy==1.6.0 where I get this error I mentioned in the title.

Am I in a situation where my version of python is too new for an older version of numpy and my version of numpy is too new for the script I need to run?

I'm new to all this and any information, advice or general education would be greatly appreciated.

3
  • Which version of Python are you running? Which OS is this on? Commented Sep 18, 2024 at 10:54
  • And which version of Pandas? Commented Sep 18, 2024 at 10:56
  • I'm running python 3.12 on Linux Mint and I can't figure out how to find out what version of pandas I have installed, but upon just trying to import pandas to discover this I get that same error: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject ---- so actually it's nothing to do with the script I'm running. Is it that my version of numpy is incompatible with my version of pandas? Commented Sep 18, 2024 at 11:09

1 Answer 1

0

This error is likely due to an incompatibility between your versions of NumPy and pandas. This often happens when the two libraries are built with different versions of their underlying C dependencies, leading to binary incompatibility.

First, check the installed versions of numpy and pandas using the following command:

python -c "import numpy; import pandas; print(f'NumPy version: {numpy.__version__}'); print(f'pandas version: {pandas.__version__}')"

Try reinstalling both numpy and pandas to ensure they are compatible and correctly installed:

pip uninstall numpy pandas
pip install numpy pandas

Install specific versions using:

pip install numpy==1.26.0 pandas==2.1.0

Additional Information:-

If you have other libraries that depend on NumPy or pandas (like SciPy or Matplotlib), they may also cause conflicts. You can check for package conflicts using:

pip check

This command will report any broken or incompatible packages.

Also, to avoid system-wide package conflicts, it's a good practice to create a virtual environment and install the necessary packages there:

python -m venv myenv
source myenv/bin/activate
pip install numpy pandas
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.