A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.4.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 "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\test_classify\classify.py", line 3, in <module>
import cv2
File "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\.venv\Lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\.venv\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "C:\Users\playdata2\AppData\Local\Programs\Python\Python311\Lib\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 "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\test_classify\classify.py", line 3, in <module>
import cv2
File "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\.venv\Lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "E:\study\sk_playdata\study_ai\ml_workspace\day26_ml_model_save_use\testcv\.venv\Lib\site-packages\cv2\__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\playdata2\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy.core.multiarray failed to import
종료 코드 1(으)로 완료된 프로세스
OpenCV(cv2)는 NumPy 1.x 기준으로 컴파일됨
그런데 현재 환경은 NumPy 2.4.6
NumPy 2.x와 OpenCV의 호환성 문제
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.4.6
AttributeError: _ARRAY_API not found
터미널에서 다시 버전을 맞춰주자.
제일 안정적인 버전은 아래와같다 .
Python 3.10~3.11
numpy 1.26.4
opencv-python 4.8.x
pip uninstall opencv-python
pip install opencv-python==4.8.1.78
pip install numpy==1.26.4

! CAFFE GoogLeNet은 반드시 input layer 이름이 필요한 경우가 있다. 주석하지말것.
