错误地找到MediaPipe lib,但它存在于文件夹中
trackback(最近的最新通话):文件 “ c:\ users \ shash \ desktop \ extras \ traning_placement \ project_python \ hand_tracking \ hand_tracking_min.py”, 第2行,IN 导入MediaPipe作为MP文件“ C:\ Users \ Shash \ AppData \ Local \ Program \ Python \ Python \ Python39 \ lib \ lib \ lib \ site-packages \ Mediapipe_ inpipe_ init> in. 第17行,在 导入MediaPipe.python.Solutions作为解决方案文件“ C:\ Users \ Shash \ AppData \ local \ program \ python \ python \ python39 \ lib \ lib \ lib \ site-packages \ MediaPipe \ python \ python \ python \ solutions_ solutions_ solutions_ inse init> init> init> in Ins _。py”。 ,,,, 第17行,在 导入MediaPipe.python.solutions.drawing_styles文件“ C:\ Users \ Shash \ AppData \ local \ Program \ python \ python \ python39 \ lib \ lib \ lib \ site-packages \ Mediapipe \ Mediapipe \ python 第20行,
来自MediaPipe.python.solutions.drawing_utils导入图纸文件文件 “ c:\ users \ shash \ appdata \ local \ program \ python \ python39 \ lib \ lib \ site-packages \ mediapipe \ python \ python \ solutions \ solutions \ solutions \ drawd_utils.py”, 第25行,
来自MediaPipe.framework.formats导入distion_pb2文件“ C:\ Users \ shash \ appdata \ local \ program \ python \ python \ python \ python39 \ lib \ lib \ site-packages \ Mediapipe \ Mediapipe \ Mediapipe \ framework \ Framework \ Framework \ Fracework \ Femmats \ detection \ detection_pb2.py”, 第16行,
来自MediaPipe.framework.formats导入location_data_pb2 as MediaPipe_dot_framework_dot_dot_formats_dot_location__data__pb2 file file “ c:\ users \ shash \ appdata \ local \ program \ python \ python \ python39 \ lib \ site-packages \ mediapipe \ mediapipe \ framework \ framework \ formatats \ location_data_pb2.py”, 第16行,在 来自MediaPipe.framework.formats.annotation导入rasterization_pb2 as MediaPipe_Dot_framework_dot_formats_dot_annotation_dot_rasterization__pb2 文件 “ c:\ users \ shash \ appdata \ local \ program \ python \ python \ python39 \ lib \ site-packages \ mediapipe \ mediapipe \ framework \ framework \ format \ notation \ antotation \ antotation \ rasterization_pb2.py”, 第36行,英寸 _descriptor.fielddescriptor(文件“ c:c:\ users \ shash \ appdata \ local \ program \ program \ python \ python \ python39 \ lib \ lib \ lib \ site-packages \ google \ google \ proceobuf \ proceobuf \ procebuf \ descriptor.py”, 第560行, new _MESSAGE.MESSAGE._CHECKCALLEDFROMGENERATEDFILE()typeError:无法直接创建描述符。如果这个电话来自 _pb2.py文件,您生成的代码已过时,必须使用Protoc> = 3.19.0再生。如果你不能立即 再生您的原始人,其他一些可能的解决方法是:
- 将Protobuf软件包降级到3.20.x或更低。
- set protocol_buffers_python_implementation = python(但这将使用纯Python解析,并且会慢得多)。
这是我写的程序:
import cv2
import mediapipe as mp
import time
cap = cv2.VideoCapture(0)
while True:
success,img=cap.read()
cv2.imshow("Image",img)
cv2.waitKey(1)
Traceback (most recent call last): File
"c:\Users\shash\Desktop\Extras\Traning_Placement\Projects_python\hand_tracking\Hand_Tracking_Min.py",
line 2, in
import mediapipe as mp File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe_init_.py",
line 17, in
import mediapipe.python.solutions as solutions File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions_init_.py",
line 17, in
import mediapipe.python.solutions.drawing_styles File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\drawing_styles.py",
line 20, in
from mediapipe.python.solutions.drawing_utils import DrawingSpec File
"C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\drawing_utils.py",
line 25, in
from mediapipe.framework.formats import detection_pb2 File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\detection_pb2.py",
line 16, in
from mediapipe.framework.formats import location_data_pb2 as mediapipe_dot_framework_dot_formats_dot_location__data__pb2 File
"C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\location_data_pb2.py",
line 16, in
from mediapipe.framework.formats.annotation import rasterization_pb2 as
mediapipe_dot_framework_dot_formats_dot_annotation_dot_rasterization__pb2
File
"C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\annotation\rasterization_pb2.py",
line 36, in
_descriptor.FieldDescriptor( File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\google\protobuf\descriptor.py",
line 560, in new
_message.Message._CheckCalledFromGeneratedFile() TypeError: Descriptors cannot not be created directly. If this call came from a
_pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately
regenerate your protos, some other possible workarounds are:
- Downgrade the protobuf package to 3.20.x or lower.
- Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
And this is the program I wrote:
import cv2
import mediapipe as mp
import time
cap = cv2.VideoCapture(0)
while True:
success,img=cap.read()
cv2.imshow("Image",img)
cv2.waitKey(1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
今天我面临同样的问题,同时我尝试在Google Colab中运行代码,并且效果很好。
I faced the same issue today, I tried to run the code in google Colab in the meantime and it worked well.
您可以更新Protobuf版本。
You can update the version of protobuf.