Skip to content

ImportError: numpy.core.multiarray --- Numpy 2.0.0 #995

Closed as not planned
Closed as not planned
@JuliusBairaktaris

Description

@JuliusBairaktaris

Expected behaviour

I am currently using NumPy 2.0.0rc2 in conjunction with the recently released OpenCV 4.10.0.82 and have encountered the following error:

Actual behaviour

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0rc2 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 "heuristic.py", line 4, in <module>
    import cv2
  File "AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2\__init__.py", line 181, in <module>
    bootstrap()
  File "AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "heuristic.py", line 4, in <module>
    import cv2
  File "AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2\__init__.py", line 181, in <module>
    bootstrap()
  File "AppData\Local\Programs\Python\Python312\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy.core.multiarray failed to import

Steps to reproduce

  • Windows 11
  • Python 3.12.3
  • opencv-python==4.10.0.82
  • numpy==2.0.0rc2
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

Kind regards,

Julius Bairaktaris

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions