错误地找到MediaPipe lib,但它存在于文件夹中

发布于 2025-02-05 18:03:40 字数 2918 浏览 3 评论 0原文

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再生。如果你不能立即 再生您的原始人,其他一些可能的解决方法是:

  1. 将Protobuf软件包降级到3.20.x或更低。
  2. 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:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三寸金莲 2025-02-12 18:03:40

今天我面临同样的问题,同时我尝试在Google Colab中运行代码,并且效果很好。

I faced the same issue today, I tried to run the code in google Colab in the meantime and it worked well.

萌辣 2025-02-12 18:03:40

您可以更新Protobuf版本。

pip uninstall protobuf
pip install protobuf==3.20.1

You can update the version of protobuf.

pip uninstall protobuf
pip install protobuf==3.20.1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文