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 problems #1245

Open ian1447 opened 3 years ago

ian1447 commented 3 years ago

Description

Made a project using face_recognition for attendance but for some reason the library face_recognition makes the .exe file unable to run and it shows on the screen "Failed to execute script". I am using pyinstaller to make an executable file. I am also using VScode with this project.

What I Did

I reinstalled everything from python to dlib to face_recognition and it still shows the same error when I run the .exe file. I have already tried putting 'C:\Users\ian jamora\AppData\Local\Programs\Python\Python39\Lib\site-packages\face_recognition_models','face_recognition,models' on the .datas =[ ] in the .spec but it still doesn't work for me.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

this is what shows after using pysintaller with my code

58 INFO: PyInstaller: 4.0 59 INFO: Python: 3.9.0 59 INFO: Platform: Windows-10-10.0.19041-SP0 65 INFO: UPX is not available. Traceback (most recent call last): File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\ian jamora\AppData\Local\Programs\Python\Python39\Scripts\pyinstaller.exe__main.py", line 7, in File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller__main__.py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\main__.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 664, in build code = compile(f.read(), spec, 'exec') File "tryguiwithrecog.spec", line 9 datas=['C:\Users\ian jamora\AppData\Local\Programs\Python\Python39\Lib\site-packages\face_recognition_models','face_recognition,models'], ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

C:\Users\ian jamora\Documents\SoftEng>pyinstaller --onedir -w tryguiwithrecog.py 62 INFO: PyInstaller: 4.0 62 INFO: Python: 3.9.0 62 INFO: Platform: Windows-10-10.0.19041-SP0 78 INFO: wrote C:\Users\ian jamora\Documents\SoftEng\tryguiwithrecog.spec 78 INFO: UPX is not available. 78 INFO: Extending PYTHONPATH with paths ['C:\Users\ian jamora\Documents\SoftEng', 'C:\Users\ian jamora\Documents\SoftEng'] 172 INFO: checking Analysis 172 INFO: Building Analysis because Analysis-00.toc is non existent 172 INFO: Initializing module dependency graph... 172 INFO: Caching module graph hooks... 250 INFO: Analyzing base_library.zip ... 3859 INFO: Processing pre-find module path hook distutils from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'. 3869 INFO: distutils: retargeting to non-venv dir 'c:\users\ian jamora\appdata\local\programs\python\python39\lib' 7995 INFO: Caching module dependency graph... 8122 INFO: running Analysis Analysis-00.toc 8214 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by c:\users\ian jamora\appdata\local\programs\python\python39\python.exe 8365 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\ian jamora\appdata\local\programs\python\python39\python39.dll 8379 INFO: Analyzing C:\Users\ian jamora\Documents\SoftEng\tryguiwithrecog.py 10901 INFO: Processing pre-find module path hook site from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-site.py'. 10904 INFO: site: retargeting to fake-dir 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\fake-modules' 12321 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-setuptools.extern.six.moves.py'. 16282 INFO: Processing module hooks... 16282 INFO: Loading module hook 'hook-cv2.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 16297 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks'... 16501 INFO: Loading module hook 'hook-distutils.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 16517 INFO: Loading module hook 'hook-encodings.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 16594 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 16641 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 16766 INFO: Loading module hook 'hook-numpy.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 16766 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 17391 INFO: Loading module hook 'hook-PIL.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 17407 INFO: Import to be excluded not found: 'PyQt4' 17407 INFO: Excluding import 'tkinter' 17407 INFO: Removing import of tkinter from module PIL.ImageTk 17407 INFO: Excluding import 'PyQt5' 17407 INFO: Removing import of PyQt5 from module PIL.ImageQt 17407 INFO: Import to be excluded not found: 'PySide' 17407 INFO: Import to be excluded not found: 'FixTk' 17407 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 17407 INFO: Excluding import 'tkinter' 17407 INFO: Import to be excluded not found: 'FixTk' 17407 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 17937 INFO: Processing pre-safe import module hook win32com from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\_pyinstaller_hooks_contrib\hooks\pre_safe_import_module\hook-win32com.py'. Traceback (most recent call last): File "", line 2, in ModuleNotFoundError: No module named 'win32com' 18016 INFO: Processing pre-safe import module hook win32com from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\_pyinstaller_hooks_contrib\hooks\pre_safe_import_module\hook-win32com.py'. Traceback (most recent call last): File "", line 2, in ModuleNotFoundError: No module named 'win32com' 18109 WARNING: Hidden import "pkg_resources.py2_warn" not found! 18109 WARNING: Hidden import "pkg_resources.markers" not found! 18109 INFO: Excluding import 'main' 18109 INFO: Removing import of main from module pkg_resources 18109 INFO: Loading module hook 'hook-setuptools.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first. warnings.warn( 18687 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 18703 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 18703 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 18703 INFO: Loading module hook 'hook-xml.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 18703 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks'... 19036 INFO: checking Tree 19037 INFO: Building Tree because Tree-00.toc is non existent 19038 INFO: Building Tree Tree-00.toc 19135 INFO: checking Tree 19135 INFO: Building Tree because Tree-01.toc is non existent 19137 INFO: Building Tree Tree-01.toc 19186 INFO: Looking for ctypes DLLs 19236 INFO: Analyzing run-time hooks ... 19241 INFO: Including run-time hook 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py' 19257 INFO: Including run-time hook 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py' 19278 INFO: Including run-time hook 'c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth__tkinter.py' 19296 INFO: Looking for dynamic libraries 21156 INFO: Looking for eggs 21156 INFO: Using Python library c:\users\ian jamora\appdata\local\programs\python\python39\python39.dll 21156 INFO: Found binding redirects: [] 21172 INFO: Warnings written to C:\Users\ian jamora\Documents\SoftEng\build\tryguiwithrecog\warn-tryguiwithrecog.txt 21250 INFO: Graph cross-reference written to C:\Users\ian jamora\Documents\SoftEng\build\tryguiwithrecog\xref-tryguiwithrecog.html 21360 INFO: checking PYZ 21360 INFO: Building PYZ because PYZ-00.toc is non existent 21360 INFO: Building PYZ (ZlibArchive) C:\Users\ian jamora\Documents\SoftEng\build\tryguiwithrecog\PYZ-00.pyz 22359 INFO: Building PYZ (ZlibArchive) C:\Users\ian jamora\Documents\SoftEng\build\tryguiwithrecog\PYZ-00.pyz completed successfully. 22379 INFO: checking PKG 22379 INFO: Building PKG because PKG-00.toc is non existent 22379 INFO: Building PKG (CArchive) PKG-00.pkg 22426 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 22427 INFO: Bootloader c:\users\ian jamora\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe 22427 INFO: checking EXE 22431 INFO: Building EXE because EXE-00.toc is non existent 22431 INFO: Building EXE from EXE-00.toc 22432 INFO: Appending archive to EXE C:\Users\ian jamora\Documents\SoftEng\build\tryguiwithrecog\tryguiwithrecog.exe 22461 INFO: Building EXE from EXE-00.toc completed successfully. 22465 INFO: checking COLLECT 22466 INFO: Building COLLECT because COLLECT-00.toc is non existent 22467 INFO: Building COLLECT COLLECT-00.toc 37749 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Edith-panda commented 3 years ago

hey ian! i have windows 10 python 3.9.0 I run face_recognition in visual studio code terminal as pip install face_recognition first time i have a long error becoz i have not fulfilled all library requirements such as visual studio community for c++ so see if thats a problem else see for opencv, CMake ,Click, numpy this favours in installation of face_recogniton

pip install face_recognition Requirement already satisfied: face_recognition in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (1.3.0) Requirement already satisfied: numpy in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (from face_recognition) (1.19.3) Requirement already satisfied: face-recognition-models>=0.3.0 in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (from face_recognition) (0.3.0) Requirement already satisfied: Click>=6.0 in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (from face_recognition) (7.1.2) Requirement already satisfied: dlib>=19.7 in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (from face_recognition) (19.21.0) Requirement already satisfied: Pillow in c:\users\yasha\appdata\local\programs\python\python39\lib\site-packages (from face_recognition) (8.0.1)