Home > Mobile >  Error finding the mediapipe lib but it is present in the folder
Error finding the mediapipe lib but it is present in the folder

Time:06-08

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)

CodePudding user response:

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

CodePudding user response:

You can update the version of protobuf.

pip uninstall protobuf
pip install protobuf==3.20.1
  • Related