Skip to content

Incompatibility with Numpy 2 #20

@ldouteau

Description

@ldouteau

Description

Pyhams fails at import when Numpy 2 is installed. Tested agains several versions of Numpy on Python 3.12, Windows OS

  • Import works with Numpy 1.26.4
  • Import fails with Numpy 2.0.0 and 2.2.4

Spotted while trying to run RAFT

Steps to reproduce issue

Please provide a minimum working example (MWE) if possible

  1. Install Pyhams in a fresh venv pip install pyhams. Comes with Numpy 2.2.4
  2. Run import pyhams.pyhams

Current behavior

Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyhams.pyhams

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "C:\...\venv\Lib\site-packages\pyhams\pyhams.py", line 5, in <module>
    import pyhams._hams as hams
Traceback (most recent call last):
  File "C:\...\venv\Lib\site-packages\numpy\core\_multiarray_umath.py", line 44, in __getattr__
    raise ImportError(msg)
ImportError:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\...\venv\Lib\site-packages\pyhams\pyhams.py", line 5, in <module>
    import pyhams._hams as hams
ImportError: numpy.core.multiarray failed to import

Expected behavior

Should import properly

Code versions

List versions only if relevant

  • Python 3.12
  • Pyhams 1.3.0
  • Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions