Closed roydenwa closed 8 months ago
Hi,
I've encountered the same problem (opencv-python==4.5.5.64), can you let me know what version of opencv version you switched to in order to resolve it?
opencv-python==4.8.0.74 seems to work. I will open a PR.
It appears updating open-cv to another version doesn't really work for me, as I just get the error when running:
Traceback (most recent call last): File "anonymize.py", line 1, in <module> import cv2 File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/opt/conda/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 "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/opt/conda/lib/python3.8/site-packages/cv2/gapi/__init__.py", line 301, in <module> cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)
Googling the errors appear to show that its caused by to multiple opencv installations, but adding the line:
RUN pip uninstall opencv-python opencv-contrib-python opencv-contrib-python-headless opencv-python-headless --yes
before installing dependencies in the docker file doesn't appear change anything.
You are right my workaround is to change the entry point of the container to start a bash terminal and then install pip install opencv-python==4.8.0.74
in the container. Afterwards, running the anonymize.py script works. However, I also don't know why changing the opencv version in the Dockerfile throws the GStreamer error.
nothings worked, after tried those approaches
import cv2
File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/opt/conda/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 "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/conda/lib/python3.8/site-packages/cv2/mat_wrapper/__init__.py", line 33, in <module>
cv._registerMatType(Mat)
AttributeError: partially initialized module 'cv2' has no attribute '_registerMatType' (most likely due to a circular import)
opencv-python==4.8.0.74 seems to work. I will open a PR.
tks,my problem solved!
opencv-python==4.8.0.74
does not work for me, however opencv-python-headless==4.5.5.64
does! I also needed to add ftfy==6.1.3
as requirement into the Dockerfile as well.
Hi,
unfortunately, I get the following error when using your dockerfile to build a container and test the code: AttributeError: module 'cv2.dnn' has no attribute 'DictValue'
I think it is an issue with the opencv version, since installing a newer version inside the container resolves it.