opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Numpy 2 compatible build

Open dkbarn opened this issue 7 months ago • 0 comments

I haven't managed to find any previous discussion about this, although I'm surprised by that so I very well may have missed it.

Numpy 2 is coming: https://github.com/numpy/numpy/issues/24300

Are there any plans to begin providing nightly builds of OpenCV Python bindings which are ABI compatible with Numpy 2? Instructions are provided here on how to do that: https://numpy.org/devdocs/dev/depending_on_numpy.html#numpy-2-0-specific-advice

Currently when I pip install opencv-python-rolling it is not ABI compatible:

# create a virtualenv
$ python -m venv testvenv

# install numpy 2.x
$ testvenv/bin/pip install --pre -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy

# install opencv-python-rolling
$ testvenv/bin/pip install opencv-python-rolling

$ testvenv/bin/python
>>> import cv2
RuntimeError: module compiled against ABI version 0x1000009 but this version of numpy is 0x2000000
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/share/dev/src/testvenv/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/share/dev/src/testvenv/lib/python3.10/site-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

dkbarn avatar Jan 03 '24 22:01 dkbarn