Comments (6)
Error message for googling:
python3.9
Python 3.9.5 (default, Nov 23 2021, 15:27:38)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2 as cv
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 "<stdin>", line 1, in <module>
File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.9/importlib/__init__.py", line 127, 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 "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: numpy.core.multiarray failed to import
from opencv-python.
Patch: #1002
Release: https://github.com/opencv/opencv-python/releases/tag/84
from opencv-python.
OpenCV team works on new packages release. As short term solution you can re-build OpenCV-Python package with Numpy 2 from sources.
from opencv-python.
from opencv-python.
Error message for googling:
python3.9 Python 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 as cv 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 "<stdin>", line 1, in <module> File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/usr/lib/python3.9/importlib/__init__.py", line 127, 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 "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/home/ksenia/.local/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: numpy.core.multiarray failed to import
I checked the source code https://github.com/opencv/opencv/blob/4bf95ac2df822db8608c94d891f5edf8c549a03f/modules/python/package/cv2/__init__.py#L12 seems this numpy.core.multiarray is only imported but not used anywhere.
from opencv-python.
I still see this import error on Ubuntu 22.0.4 LTS - but not on macOS - because the build system is pulling numpy 2 instead of numpy 1.x:
Collecting opencv-python-headless==4.10.0.84 (from -r requirements.txt (line 28))
Downloading opencv_python_headless-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Collecting opencv-contrib-python-headless==4.10.0.84 (from -r requirements.txt (line 29))
Downloading opencv_contrib_python_headless-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Collecting numpy (from -r requirements.txt (line 43))
Downloading numpy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
...
RuntimeError: module compiled against ABI version 0x1000009 but this version of numpy is 0x2000000
ImportError while loading conftest '/home/runner/work/medical-document-ai/medical-document-ai/test/conftest.py'.
test/conftest.py:11: in <module>
from src.app import (
src/app.py:23: in <module>
from src.services.etl.scheduled_job import ScheduledJobManager
src/services/etl/scheduled_job.py:11: in <module>
from src.services.etl.common.ocr_service import OCRService
src/services/etl/common/ocr_service.py:8: in <module>
import cv2
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/cv2/__init__.py:[18](https://github.com/umayrh/medical-document-ai/actions/runs/9734645918/job/26862931680#step:7:19)1: in <module>
bootstrap()
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/cv2/__init__.py:153: in bootstrap
native_module = importlib.import_module("cv2")
E ImportError: numpy.core.multiarray failed to import
from opencv-python.
Related Issues (20)
- PyPI: macOS arm64 wheel missing
- cv2.createThinPlateSplineShapeTransformer not exist in 4.10
- imdecode jpeg2000 segfault or deadlock in multithreading HOT 2
- Typing of compare does not allow scalar for src1 or src2
- Why Building wheel for opencv-python when using "pip install opencv-python"
- Typing stubs generation has failed when building wheel HOT 1
- error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\convolution_layer.cpp:396: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'
- Gstreamer support on windows 10
- why ı am getting this error
- BUG: cv2.fillPoly() causing segmentation fault on Ubuntu 22.04.4 LTS HOT 1
- [Suggestion] Metapackage as solution to current issues with opencv as dependency HOT 1
- Build from source python 3.12 fails HOT 6
- error: OpenCV(4.8.0) /io/opencv/modules/core/src/copy.cpp:71: error: (-215:Assertion failed) cn <= 4 in function 'scalarToRawData'
- ModuleNotFoundError: No module named 'distutils' in latest release HOT 7
- MacOS arm64 wheels missing from PyPI 4.10 release HOT 2
- ImportError: numpy.core.multiarray --- Numpy 2.0.0 HOT 1
- cv2/cv2.abi3.so, 2): Library not loaded: /usr/local/opt/libunistring/lib/libunistring.2.dylib Referenced from: /usr/local/opt/gnutls/lib/libgnutls.30.dylib HOT 1
- compile bug
- AttributeError: module 'numpy' has no attribute 'object'. `np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv-python.