Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy 2.0.0 compatibility #232

Closed
2sn opened this issue Jun 18, 2024 · 1 comment
Closed

Numpy 2.0.0 compatibility #232

2sn opened this issue Jun 18, 2024 · 1 comment

Comments

@2sn
Copy link

2sn commented Jun 18, 2024

Description of the bug
the module does not seem to import or be compatible with Numpy 2.0.0. At least, I cannot import it.

To Reproduce

import quaternion

output

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 "/home/alex/Python/bin/ipython3", line 8, in <module>
    sys.exit(start_ipython())
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/__init__.py", line 130, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/home/alex/Python/lib/python3.11/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/terminal/ipapp.py", line 317, in start
    self.shell.mainloop()
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 917, in mainloop
    self.interact()
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 910, in interact
    self.run_cell(code, store_history=True)
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3075, in run_cell
    result = self._run_cell(
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3130, in _run_cell
    result = runner(coro)
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/async_helpers.py", line 129, in _pseudo_sync_runner
    coro.send(None)
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3334, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3517, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/home/alex/Python/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-aaca8c47d265>", line 1, in <module>
    import quaternion
  File "/home/alex/Python/lib/python3.11/site-packages/quaternion/__init__.py", line 27, in <module>
    from .numpy_quaternion import (
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
AttributeError: _ARRAY_API not found
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import quaternion

File ~/Python/lib/python3.11/site-packages/quaternion/__init__.py:27
      9 __all__ = ['quaternion',
     10            'as_quat_array', 'as_spinor_array',
     11            'as_float_array', 'from_float_array',
   (...)
     21            'zero', 'one', 'x', 'y', 'z', 'integrate_angular_velocity',
     22            'squad', 'slerp', 'derivative', 'definite_integral', 'indefinite_integral']
     25 import numpy as np
---> 27 from .numpy_quaternion import (
     28     quaternion, _eps, slerp_evaluate, squad_evaluate,
     29     # slerp_vectorized, squad_vectorized, slerp, squad,
     30 )
     31 from .quaternion_time_series import (
     32     unflip_rotors, slerp, squad, integrate_angular_velocity, minimal_rotation, angular_velocity,
     33 )
     34 from .calculus import (
     35     derivative, antiderivative, definite_integral, indefinite_integral,
     36     fd_derivative, fd_definite_integral, fd_indefinite_integral,
     37     spline_derivative, spline_definite_integral, spline_indefinite_integral,
     38 )

ImportError: numpy.core.multiarray failed to import

I tried to trick pip into compiling numpy-quaternion with numpy 2.0.0, but that seems to be futile

pip install --force-reinstall --compile --no-cache-dir --no-binary numpy-quaternion numpy-quaternion
Collecting numpy-quaternion
  Downloading numpy-quaternion-2023.0.3.tar.gz (65 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.5/65.5 kB 8.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy>=1.13 (from numpy-quaternion)
  Downloading numpy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 154.8 MB/s eta 0:00:00
Downloading numpy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.3/19.3 MB 125.7 MB/s eta 0:00:00
Building wheels for collected packages: numpy-quaternion
  Building wheel for numpy-quaternion (pyproject.toml) ... done
  Created wheel for numpy-quaternion: filename=numpy_quaternion-2023.0.3-cp311-cp311-linux_x86_64.whl size=182442 sha256=0b1f898955cbf4ed24a776ea7d0e6b60662181a78e8827c61d0b737d99339642
  Stored in directory: /tmp/pip-ephem-wheel-cache-iee3uyuc/wheels/a1/3b/70/37050cd60c4f0c72580f9fe7ff85af87d111563fa30c65a70f
Successfully built numpy-quaternion
Installing collected packages: numpy, numpy-quaternion
  Attempting uninstall: numpy
    Found existing installation: numpy 2.0.0
    Uninstalling numpy-2.0.0:
      Successfully uninstalled numpy-2.0.0
  Attempting uninstall: numpy-quaternion
    Found existing installation: numpy-quaternion 2023.0.3
    Uninstalling numpy-quaternion-2023.0.3:
      Successfully uninstalled numpy-quaternion-2023.0.3
Successfully installed numpy-2.0.0 numpy-quaternion-2023.0.3

but same result when loading, seems to use different numpy to compile and link.

Expected behavior
module loads ...

Environment (please complete the following information):

  • OS, including version
    Fedore 40
  • Installation method (conda, pip, or compiled from source)
    pip
  • Numpy version (use np.version.version)
    2.0.0
  • Quaternion version (use quaternion.__version__)
    numpy-quaternion-2023.0.3 (from install, as quaternion does not import)

Additional context
Any help/fixes would be appreciated.

@moble
Copy link
Owner

moble commented Jun 19, 2024

Duplicate of #229

@moble moble marked this as a duplicate of #229 Jun 19, 2024
@moble moble closed this as completed Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants