dlaidig / vqf

137 stars 24 forks source link

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

Open rmndrs89 opened 3 months ago

rmndrs89 commented 3 months ago

Hi Daniel,

I tried to install vqf via poetry in a new project on my Windows 10 Professional operating system, however it complains about some numpy.dtype error. I am not sure what is happening here, so I was hoping that you may have a clue?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Projects\mimumove\.venv\lib\site-packages\vqf\__init__.py", line 5, in <module>
    from .vqf import VQF, offlineVQF
  File "vqf\vqf.pyx", line 1, in init vqf.vqf
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

To get there error, I did the following:

  1. Start a new Windows Powershell session.
  2. Navigate to the projects folder: cd D:\Projects.
  3. Start a new poetry project: poetry new mimumove.
  4. Install Python libraries:
    poetry add numpy scipy matplotlib
    poetry add vqf qmt
  5. Start a Python session: python
  6. Import the libraries: from vqf import VQF, BasicVQF, PyVQF

I have also tried using a venv virtual environment rather than a poetry environment, but it gives the same error. Is this something related to vqf or numpy?

Best regards, Robbin

rmndrs89 commented 3 months ago

It may have to do with the new numpy release, I didn't realize this. Will try with a downgraded numpy version.

EDIT: Yes, this seems to have been the issue. I changed the numpy version in my pyproject.toml to numpy = "^1.26.0" and not with numpy 1.26.4 I can do from vqf import VQF as before.

dlaidig commented 3 months ago

Hi Robin,

Thanks for reporting this! I've seen a similar error with the jump to numpy 1.20. So this is certainly caused by the breaking changes in the ABI of numpy 2.0.

Unless there are other issues caused by the new numpy release, I think vqf should work fine when installing from source rather than using the binary wheels. (I think the --no-binary parameter of pip should do the trick but I didn't test this. Or you can clone the repo and install the package from there.)

I'll try to find some solution without breaking the package for users of numpy < 2.0. Suggestions are welcome.

dlaidig commented 3 months ago

Note for myself: https://numpy.org/devdocs/dev/depending_on_numpy.html