ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
52.8k stars 13.42k forks source link

PyInstaller + face_recognition Exe Runtime Error #1116

Open SamratSahoo opened 4 years ago

SamratSahoo commented 4 years ago

Description

I was trying to execute an exe file I had made using PyInstaller that utilized the face_recognition library. Unfortunately when executing the file, I got a Runtime Error. I saw a similar error (#628) which told me to install the models but after runningpip install face_recognition_models and remaking the exe, I am still getting this error.

Error:

RuntimeError: Unable to open /tmp/_MEIJebbbx/face_recognition_models/models/shape_predictor_68_face_landmarks.dat

Full Error Message:

Traceback (most recent call last):
  File "Interface.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "Camera.py", line 5, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "face_recognition/__init__.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "face_recognition/api.py", line 20, in <module>
RuntimeError: Unable to open /tmp/_MEI4LEO3U/face_recognition_models/models/shape_predictor_68_face_landmarks.dat
[9073] Failed to execute script Interface

Any and all insight is appreciated. Thanks!

Latestion commented 4 years ago

It is just - pip install face_recognition. I think.

SamratSahoo commented 4 years ago

It is just - pip install face_recognition. I think.

In order to install the face_recognition library (which I have already done) you need pip install face_recognition However, the error message says it cannot open face_recognition_models and so I pip installed the models as well but it is still throwing the error

WenBoNie commented 3 years ago

I have this problem, too 。 help!datas=[('shape_predictor_68_face_landmarks.dat','./face_recognition_models/models'),('shape_predictor_5_face_landmarks.dat','./face_recognition_models/models'),('mmod_human_face_detector.dat','./face_recognition_models/models'),('dlib_face_recognition_resnet_model_v1.dat','./face_recognition_models/models')],

i use this,that is run

ibrahimcanpolat commented 2 years ago

Can you fix that?

ranarashid426 commented 2 years ago
  • Python version: 3.6
  • Operating System: Ubuntu 18.04

Description

I was trying to execute an exe file I had made using PyInstaller that utilized the face_recognition library. Unfortunately when executing the file, I got a Runtime Error. I saw a similar error (#628) which told me to install the models but after runningpip install face_recognition_models and remaking the exe, I am still getting this error.

Error:

RuntimeError: Unable to open /tmp/_MEIJebbbx/face_recognition_models/models/shape_predictor_68_face_landmarks.dat

Full Error Message:

Traceback (most recent call last):
  File "Interface.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "Camera.py", line 5, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "face_recognition/__init__.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "/home/samrat/Documents/Facial-Recognition-Attendance-Tracker/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "face_recognition/api.py", line 20, in <module>
RuntimeError: Unable to open /tmp/_MEI4LEO3U/face_recognition_models/models/shape_predictor_68_face_landmarks.dat
[9073] Failed to execute script Interface

Any and all insight is appreciated. Thanks!

Did you find any solution?

boogaming commented 1 year ago

Use pyinstaller -c PyFileName.py (with console) or pyinstaller -w PyFileName.py (without console) instead of pyinstaller --onefile PyFileName.py. Then add folder containing face_recognition models .dat files. Example, "face_recognition_models/models/shape_predictor_68_face_landmarks.dat" in the same folder of the executable file.