-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Python Typing module is incompatible with some Numpy versions #23822
Copy link
Copy link
Closed
Description
System Information
OS: Ubuntu 18.04
Python: 3.8.0 (from apt)
OpenCV: 4.x
Detailed description
Numpy: 1.24.3 Importing issue:
alexander@paradox:~/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages$ python3.8
Python 3.8.0 (default, Dec 9 2021, 17:53:27)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/typing/__init__.py", line 73, in <module>
MatLike = typing.Union[cv2.mat_wrapper.Mat, numpy.ndarray[typing.Any, numpy.dtype[numpy.generic]]]
TypeError: Type subscription requires python >= 3.9
Numpy 1.20.2:
Python 3.8.0 (default, Dec 9 2021, 17:53:27)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/mnt/projects/Projects/OpenCV/opencv-build/install/lib/python3.8/site-packages/cv2/typing/__init__.py", line 73, in <module>
MatLike = typing.Union[cv2.mat_wrapper.Mat, numpy.ndarray[typing.Any, numpy.dtype[numpy.generic]]]
TypeError: 'numpy._DTypeMeta' object is not subscriptable
Steps to reproduce
python3.8:
import cv2
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable