Skip to content

Getting error "A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash" in 4.12.0.88 #1149

@hitochan777

Description

@hitochan777

I am trying to install the latest version (4.12.0.88) with numpy 2.x but I get the following error saying the module is not compiled with 1.x.
If I understand correctly, 4.12.0.88 supports numpy 2.x. Can someone give my advice on how I can fix this issue without downgrading numpy to 1.x?

Reproduction code

$ uv run main.py

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 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/pi/developer/opencv-install-failure-repro/main.py", line 1, in <module>
    import cv2
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "/home/pi/developer/opencv-install-failure-repro/main.py", line 1, in <module>
    import cv2
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy.core.multiarray failed to import

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