opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.54k stars 55.64k forks source link

AttributeError: module 'cv2.dnn' has no attribute 'DictValue' #25614

Open abhirupghosh opened 4 weeks ago

abhirupghosh commented 4 weeks ago

System Information

OpenCV python version: 4.8.0.74 Operating System / Platform: Mac OS X 14.4.1 (23E224) Python version: 3.10.14

Detailed description

I attempt to import cv2 in my code and I face the following error:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/opt/anaconda3/envs/TableExtraction/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/anaconda3/envs/TableExtraction/lib/python3.10/site-packages/cv2/__init__.py", line 175, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/opt/anaconda3/envs/TableExtraction/lib/python3.10/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/opt/anaconda3/envs/TableExtraction/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/anaconda3/envs/TableExtraction/lib/python3.10/site-packages/cv2/typing/__init__.py", line 168, in <module>
    LayerId = cv2.dnn.DictValue
AttributeError: module 'cv2.dnn' has no attribute 'DictValue'

I have attempted to reinstall cv2 in a different conda environment to no avail.

Steps to reproduce

Literally, just:

import cv2

Issue submission checklist

abhirupghosh commented 4 weeks ago

I have also attempted to use OpenCV 4.9.0.80 - the reason behind using an earlier version was a few dependencies on the earlier version of OpenCV. However, the issue persists with the updated OpenCV.