Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python unicode error -> FileNotFoundError: The path does not exist. #2677

Closed
dyc081818 opened this issue Oct 17, 2021 · 16 comments
Closed

python unicode error -> FileNotFoundError: The path does not exist. #2677

dyc081818 opened this issue Oct 17, 2021 · 16 comments
Assignees
Labels
platform:python MediaPipe Python issues type:build/install For Build and Installation issues

Comments

@dyc081818
Copy link

I use pyinstaller to compile the Python project, and finally generate an exe executable file. When the exe file path contains unicode characters, it will report an error:

Traceback (most recent call last):
File "mediapipe_facemesh.py", line 81, in
File "mediapipe_facemesh.py", line 29, in show_face_mesh
File "mediapipe\python\solutions\face_mesh.py", line 94, in init
File "mediapipe\python\solution_base.py", line 237, in init
FileNotFoundError: The path does not exist.

@dyc081818 dyc081818 added the type:support General questions label Oct 17, 2021
@sgowroji sgowroji added platform:python MediaPipe Python issues stat:awaiting response Waiting for user response type:build/install For Build and Installation issues and removed type:support General questions labels Oct 18, 2021
@sgowroji
Copy link

Hi @dyc081818, Could you please provide the steps to reproduce the above error. Thanks!

@dyc081818
Copy link
Author

I wrote a simple example script in python, like the following, it can run successfully

import sys
sys.path.append("E:/mediapipe/mp_env/Lib/site-packages")

import cv2
import mediapipe as mp

def show_face_mesh(cap_id):
    mp_drawing = mp.solutions.drawing_utils
    mp_face_mesh = mp.solutions.face_mesh
    
    cap = cv2.VideoCapture(cap_id, cv2.CAP_DSHOW)
    with mp_face_mesh.FaceMesh (
        static_image_mode=False,
        max_num_faces=1,
        min_detection_confidence=0.1,
        min_tracking_confidence=0.1) as face_mesh:

        while cap.isOpened():
            success, frame = cap.read()
            if not success: 
                print("ignore empty camera frame")
                continue
            
            frame.flags.writeable = False
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            results = face_mesh.process(frame)

            # Draw the face mesh annotations on the image.
            frame.flags.writeable = True
            frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

            if results.multi_face_landmarks is not None:
                for face_landmarks in results.multi_face_landmarks:
                    mp_drawing.draw_landmarks(
                        frame, face_landmarks, mp_face_mesh.FACEMESH_CONTOURS
                    )

            cv2.imshow('Frame', cv2.flip(frame, 1))
            if cv2.waitKey(1) & 0xFF == 27:
                break

    cap.release()
    cv2.destroyAllWindows()

if __name__ == '__main__':
    show_face_mesh(0)

But if you add Unicode characters to the path of pip site-packages, for example, like this:

import sys
sys.path.append("E:/mediapipe/mp_env/Lib/site-packages中文")

This error will appear: "FileNotFoundError: The path does not exist." It is no problem to remove the Unicode characters.

I tried to find the C++ code. The error was reported in the mediapipe/framework/deps/file_helpers.cc file. In Exists function failed to use stat to check whether the file exists.

Then I create a new C++ project and try to call the stat function. It is no problem to add Unicode characters to the path. It is not too clear why the stat function called by mediapipe fails.

@sgowroji sgowroji added stat:awaiting googler Waiting for Google Engineer's Response and removed stat:awaiting response Waiting for user response labels Oct 20, 2021
@sgowroji sgowroji assigned jiuqiant and unassigned sgowroji Oct 20, 2021
@jiuqiant
Copy link
Collaborator

Similar to #2162 (comment)?

@dyc081818
Copy link
Author

No, the title was wrong and I corrected it immediately.

I found this problem after packaging with pyinstaller, but then I tested it in the editor and the same error, indicating that it was not a problem with pyinstaller

@dyc081818 dyc081818 changed the title compile python use pyinstaller error -> FileNotFoundError: The path does not exist. unicode error -> FileNotFoundError: The path does not exist. Oct 20, 2021
@dyc081818 dyc081818 changed the title unicode error -> FileNotFoundError: The path does not exist. python unicode error -> FileNotFoundError: The path does not exist. Oct 20, 2021
@dyc081818
Copy link
Author

Has anyone encountered this problem?

@Giovannibriglia
Copy link

I have the same problem

@Fourtinato99
Copy link

+1

1 similar comment
@xesdiny
Copy link

xesdiny commented Jan 11, 2022

+1

@YaroslavFur
Copy link

This helped me with the 237 line error, I just followed the instruction of [Bar-Levav] (edited .spec file + special pyinstaller compilation command):
https://stackoverflow.com/questions/67887088/issues-compiling-mediapipe-with-pyinstaller-on-macos

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@dyc081818
Copy link
Author

This helped me with the 237 line error, I just followed the instruction of [Bar-Levav] (edited .spec file + special pyinstaller compilation command): https://stackoverflow.com/questions/67887088/issues-compiling-mediapipe-with-pyinstaller-on-macos

Thanks Reply
But obviously that approach is too cumbersome, I can offer an easier way in spec file:
a = Analysis(py_files, pathex=[], binaries=[], datas=[('Python Path/Lib/site-packages/mediapipe/modules', 'mediapipe/modules')],

The above configuration is added to copy the modules folder to the target folder, and it can run correctly
But if the path of the exe contains unicode characters, it will report an error

File "mediapipe\python\solutions\face_mesh.py", line 94, in init
File "mediapipe\python\solution_base.py", line 237, in init
FileNotFoundError: The path does not exist.

mediapipe doesn't seem to be able to find binaries in paths containing unicode

@dyc081818 dyc081818 reopened this Mar 27, 2022
@AdeniltonR
Copy link

Hello, I'm having this same problem using midiapipe, can you help me.

@kuaashish kuaashish assigned kuaashish and unassigned jiuqiant Apr 21, 2023
@kuaashish kuaashish removed the stat:awaiting googler Waiting for Google Engineer's Response label Apr 21, 2023
@kuaashish
Copy link
Collaborator

Hello @dyc081818,
We are upgrading the MediaPipe Legacy Solutions to new MediaPipe solutions However, the libraries, documentation, and source code for all the MediaPipe Legacy Solutions will continue to be available in our GitHub repository and through library distribution services, such as Maven and NPM.

You can continue to use those legacy solutions in your applications if you choose. Though, we would request you to check new MediaPipe solutions which can help you more easily build and customize ML solutions for your applications. These new solutions will provide a superset of capabilities available in the legacy solutions.

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Apr 21, 2023
@github-actions
Copy link

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions
Copy link

github-actions bot commented May 7, 2023

This issue was closed due to lack of activity after being marked stale for past 7 days.

@github-actions github-actions bot closed this as completed May 7, 2023
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@kuaashish kuaashish removed stat:awaiting response Waiting for user response stale labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:python MediaPipe Python issues type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

9 participants