I’ve got an Orin Nano DevKit running JetPack 6.1 and I’m building OpenCV with CUDA support for Python3. The trouble I encounter is that importing cv2 in Python3 fails because OpenCV is built against the Numpy 1.x.x ABI, but I need to have Numpy 2.x.x installed.
Situation details:
- CuPy installed using
python3 -m pip install cupy-cuda12x, which installs NumPy 2.2.6 as a dependency. - OpenCV built using this script.
During configuration the build reports that it is using headers for NumPy 2.2.6:
– Python 3:
– Interpreter: /usr/bin/python3 (ver 3.10.12)
– Libraries: /usr/lib/aarch64-linux-gnu/libpython3.10.so (ver 3.10.12)
– Limited API: NO
– numpy: /home/user/.local/lib/python3.10/site-packages/numpy/_core/include (ver 2.2.6)
– install path: lib/python3.10/dist-packages/cv2/python-3.10
– Python (for build): /usr/bin/python3
OpenCV builds and installs successfully, but then fails to import in Python:
Python 3.10.12 (main, Jan 26 2026, 14:55:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupy
>>> cupy.__version__
'14.0.0'
>>> import numpy
>>> numpy.__version__
'2.2.6'
>>> import cv2
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 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 "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.10/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 "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: numpy.core.multiarray failed to import
I’ve tried building in a Python virtual environment, but the results are the same.
Any ideas how to make OpenCV build with support for NumPy 2.2.6?
Thanks in advance!