CV2安装MediaPipe库后不起作用
我想使用Python制作手工跟踪程序,但是教程告诉我安装MediaPipe库,然后我安装了它。在此之前,使用CV2可以流式摄像机是可以的,但是在安装MediaPipe之后,CV2不起作用 这里的消息:
>>>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) ```
我尝试再次安装OpenCV,但请始终收到此消息:
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)
但是问题仍然存在。我该如何修复?
编辑:这是我的pip列表
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我的情况与上述相同
您可以尝试一下:
此命令成功解决了这种情况
参考: https:// https://github.com/rudrabha /wav2lip/essess/387
I have the same situation like above
you can try it:
This command has successfully resolved this situation
Reference:https://github.com/Rudrabha/Wav2Lip/issues/387
我也有类似的问题,我只安装了
opencv-python
。通过安装opencv-python-headless
来解决该问题。我的问题比这更复杂。实际上,OpenCV-Python已经安装在“ root”中,但是当我以其他用户(DEV)登录时,我会发现问题为OP。
我可以手动安装
opencv-python-headless
或opencv-contrib-python
手动,然后系统将起作用。但是,如果我将它们安装在“ root”中,则我的sill存在相同的问题。因此,我使用的最终解决方案是在我的用户环境中重新安装
opencv-python
:pip3 install-upgrade-upgrade -force-renstall opencv-python
I have similar problem, and I only have
opencv-python
installed. The problem is solved by installingopencv-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
oropencv-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
在任何版本(例如:4.6.0.66)中,当您安装任何2个包装中的任何2个软件包时:OpenCV-Contrib-Python,OpenCV-Python-Headless,OpenCV-Python,请确保它们具有相同的版本。我也遇到了同样的错误,我发现它们的版本不同。然后,同步更新解决了问题。
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.
我使用以下命令来解决这样的问题。
PIP卸载OPENCV-CONTRIB-PYTHON
PIP安装OPENCV-CONTRIB-PYTHON
I fix such a problem using the following commands.
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
以下解决方案
PIP安装“ OpenCv-Python-Headless&lt; 4.3”
已从源构建OpenCV时修复了以下错误!
the following solution
pip install "opencv-python-headless<4.3"
fixed the error below when building OpenCV from source!