Python3 Face Recognition windows exe app created using Pyinstaller not working

Viewed 342

Python version : 3.6.8

My code is running absolutely fine when I just run like this in my command line:

python mycode.py

But when I convert it into exe file using pyinstaller, getting an error.

I am running this command to convert my file to exe:

pyinstaller --onefile mycode.py

mycode.py

import tkinter

master = tkinter.Tk()
master.title("Face Recog")


def run():
    import face_recognition
    import cv2
    import numpy as np

    video_capture = cv2.VideoCapture(0)

    ....
    ....

    video_capture.release()
    cv2.destroyAllWindows()


b = tkinter.Button(master, text="Start", command=run)
b.pack()
master.mainloop()

I am importing face_recognition, cv2 and numpy in run() function because I can see the error, otherwise I couldn't see the error before, so when I click on Tkinter's start button, I get this error:

Module :  <module 'gettext' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\gettext.pyc'>
Module :  <module 'unittest.runner' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\unittest\\runner.pyc'>
Module :  <module 'unittest.signals' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\unittest\\signals.pyc'>
Module :  <module 'numpy.testing._private' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\numpy\\testing\\_private\\__init__.pyc'>
Module :  <module 'numpy.testing._private.utils' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\numpy\\testing\\_private\\utils.pyc'>
Module :  <module 'numpy.testing._private.decorators' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\numpy\\testing\\_private\\decorators.pyc'>
Module :  <module 'numpy.testing._private.nosetester' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\numpy\\testing\\_private\\nosetester.pyc'>
Module :  <module 'PIL.ImageFile' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\PIL\\ImageFile.pyc'>
Module :  <module 'face_recognition_models' from 'C:\\Users\\Himesh\\AppData\\Local\\Temp\\_MEI180162\\face_recognition_models\\__init__.pyc'>
Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1705, in __call__
  File "recognition_internal.py", line 8, in run
    import face_recognition
  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 "d:\himesh\miniconda3\envs\face\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 494, 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 "d:\himesh\miniconda3\envs\face\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 494, in exec_module
    exec(bytecode, module.__dict__)
  File "face_recognition\api.py", line 20, in <module>
RuntimeError: Unable to open C:\Users\Himesh\AppData\Local\Temp\_MEI180162\face_recognition_models\models\shape_predictor_68_face_landmarks.dat
0 Answers
Related