-
Notifications
You must be signed in to change notification settings - Fork 852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: 'numpy._DTypeMeta' object is not subscriptable #885
Labels
Comments
Same here since installed the latest version :opencv-python 4.8.0.76 File /Workspace/Repos/.internal/5dce05998b_commits/2a4e2ed1f03b86c88cd19765af7ff7bfbf793cfe/src/image_utils.py:1
----> 1 import cv2
2 import numpy as np
3 import matplotlib.image as mpimg
File /databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py:171, in _create_import_patch.<locals>.import_patch(name, globals, locals, fromlist, level)
166 thread_local._nest_level += 1
168 try:
169 # Import the desired module. If you’re seeing this while debugging a failed import,
170 # look at preceding stack frames for relevant error information.
--> 171 original_result = python_builtin_import(name, globals, locals, fromlist, level)
173 is_root_import = thread_local._nest_level == 1
174 # `level` represents the number of leading dots in a relative import statement.
175 # If it's zero, then this is an absolute import.
File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:672, in _load_unlocked(spec)
File <frozen importlib._bootstrap>:632, in _load_backward_compatible(spec)
File /databricks/python_shell/dbruntime/PostImportHook.py:218, in _ImportHookChainedLoader.load_module(self, fullname)
216 def load_module(self, fullname):
217 try:
--> 218 module = self.loader.load_module(fullname)
219 notify_module_loaded(module)
220 except (ImportError, AttributeError):
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/cv2/__init__.py:181
176 if DEBUG: print("Extra Python code for", submodule, "is loaded")
178 if DEBUG: print('OpenCV loader: DONE')
--> 181 bootstrap()
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/cv2/__init__.py:175, in bootstrap()
172 if DEBUG: print('OpenCV loader: binary extension... OK')
174 for submodule in __collect_extra_submodules(DEBUG):
--> 175 if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
176 if DEBUG: print("Extra Python code for", submodule, "is loaded")
178 if DEBUG: print('OpenCV loader: DONE')
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/cv2/__init__.py:28, in __load_extra_py_code_for_module(base, name, enable_debug_print)
26 native_module = sys.modules.pop(module_name, None)
27 try:
---> 28 py_module = importlib.import_module(module_name)
29 except ImportError as err:
30 if enable_debug_print:
File /usr/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/cv2/typing/__init__.py:69
65 import typing
68 if numpy.lib.NumpyVersion(numpy.__version__) > "1.20.0" and sys.version_info >= (3, 9):
---> 69 NumPyArrayGeneric = numpy.ndarray[typing.Any, numpy.dtype[numpy.generic]]
70 else:
71 NumPyArrayGeneric = numpy.ndarray
TypeError: 'numpy._DTypeMeta' object is not subscriptable |
It's already fixed in OpenCV 4.x branch and has not been released yet. The fix should be available with 4.9.0: opencv/opencv#23838, opencv/opencv#23927 |
FindHao
added a commit
to pytorch/benchmark
that referenced
this issue
Aug 16, 2023
According to the [upstream issue](opencv/opencv-python#885), opencv-python has some compatibility problem with numpy. Since we fixed the numpy version in the requirements.txt, we also need to fix the opencv-python's verison too. I install the nightly Torch and TorchBench, there is an installation error same with the above issue. opencv-python 4.7.0.72 works well. I think we'd better fix its version until the latest opencv-python 4.9.0 released.
facebook-github-bot
pushed a commit
to pytorch/benchmark
that referenced
this issue
Aug 17, 2023
Summary: According to the [upstream issue](opencv/opencv-python#885), opencv-python has a compatibility problem with numpy. Since we fixed the numpy version in the requirements.txt, we also need to fix the opencv-python's verison too. I install the nightly Torch and TorchBench, there is an TorchBench installation error same with the above issue with opencv-python 4.8. But opencv-python 4.7.0.72 works well. I think we'd better fix its version until the latest opencv-python 4.9.0 released. Pull Request resolved: #1829 Reviewed By: xuzhao9 Differential Revision: D48439448 Pulled By: FindHao fbshipit-source-id: da34057de3908f30f19d9999aeab800b512a49df
Duplicate for opencv/opencv#23822 |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The most recent opencv-python release appears to be break compatibility with older versions of numpy e.g. 1.21.2
Not sure you should do anything but this is probably going to break a bunch of folks with unpinned opencv version but pinned numpy version.
The text was updated successfully, but these errors were encountered: