Reputation: 29
I want to make handtracker program using python but the tutorial tell me to install mediapipe library, then I installed it. Before that it's okay using cv2 to stream my camera, but after installing mediapipe, the cv2 doesn't work here the message :
>>>import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 181, in <module>
bootstrap()
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\windows\AppData\Local\Programs\Python\Python39\lib\site-packages\cv2\gapi\__init__.py", line 290, 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) ```
I tried to install opencv again but always get this message :
Requirement already satisfied: numpy>=1.19.3 in c:\users\windows\appdata\local\programs\python\python39\lib\site-packages (from opencv-python) (1.21.1)
but the problem still there. How do I fix it?
Edited : this is my pip list
C:\Users\windows>pip list
Package Version
--------------------- --------
absl-py 1.1.0
attrs 21.4.0
cycler 0.11.0
fonttools 4.33.3
kiwisolver 1.4.2
matplotlib 3.5.2
mediapipe 0.8.10
numpy 1.21.1
opencv-contrib-python 4.6.0.66
opencv-python 4.5.3.56
packaging 21.3
Pillow 8.3.1
pip 22.1.2
protobuf 4.21.1
pygame 2.1.2
pyparsing 3.0.9
python-dateutil 2.8.2
pyzbar 0.1.8
setuptools 56.0.0
six 1.16.0
Upvotes: 2
Views: 7264
Reputation: 1
the following solution
pip install "opencv-python-headless<4.3"
fixed the error below when building OpenCV from source!
import cv2 Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py", line 181, in bootstrap() File "C:\ProgramData\Anaconda3\lib\site-packages\cv2_init_.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "C:\ProgramData\Anaconda3\lib\importlib_init_.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: DLL load failed while importing cv2: The specified module could not be found.
Upvotes: 0
Reputation: 366
In any version(ex: 4.6.0.66), when you install any 2 of 3 packages: opencv-contrib-python, opencv-python-headless, opencv-python, make sure they have the same version. I also got the same error, I found out their versions are different. Then a synchronous update solved the problem.
Upvotes: 1
Reputation: 21
I fix such a problem using the following commands.
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
Upvotes: 0
Reputation: 355
I have similar problem, and I only have opencv-python
installed. The problem is solved by installing opencv-python-headless
.
My problem is more complicate than that. Actually the opencv-python is already installed in "root", but when I login as another user (dev), I get the problem as OP.
I can install opencv-python-headless
or opencv-contrib-python
manually, then the system will work. But if I install them in "root", I sill have the same problem.
So the final solution I use is to reinstall opencv-python
in my user environment (dev):
pip3 install --upgrade --force-reinstall opencv-python
Upvotes: 1
Reputation: 61
I have the same situation like above you can try it:
pip install "opencv-python-headless<4.3"
This command has successfully resolved this situation
Reference:https://github.com/Rudrabha/Wav2Lip/issues/387
Upvotes: 6