pmneila / PyMCubes

Marching cubes (and related tools) for Python
BSD 3-Clause "New" or "Revised" License
692 stars 87 forks source link

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

Closed Tracy-coder closed 2 months ago

Tracy-coder commented 2 months ago

When I import mcubes in my python file,an error occurs.I'm very confused and wondering if anyone is having the same problem.

File "*", line 6, in <module>
    import mcubes
  File "*/site-packages/mcubes/__init__.py", line 2, in <module>
    from ._mcubes import marching_cubes, marching_cubes_func
  File "mcubes/src/_mcubes.pyx", line 2, in init mcubes._mcubes
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

environment: Python 3.10.0 PyMCubes 0.1.4 numpy 2.0.0

AlexanderJCS commented 2 months ago

Getting the same error with the following environment:

$ pip list
Package  Version
-------- -------
numpy    2.0.0
pip      24.1.1
PyMCubes 0.1.4
scipy    1.14.0

and Python 3.12.2 and Windows 10

pmneila commented 2 months ago

Indeed, there is a problem with the versions in the requirements of PyMCubes, and the precompiled packages available in pip do not yet support NumPy 2.0.

While I fix this (and possibly add support for NumPy 2.0), you can downgrade to NumPy 1.26 with

python -m pip install 'numpy~=1.26.0'

(or similar with your package manager if you don't use pip).

Thanks for reporting this and sorry for the inconvenience.

pmneila commented 2 months ago

I just uploaded a new version of PyMCubes. Just upgrade with:

python -m pip install --upgrade pymcubes

This problem should be fixed now. Thanks!