Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

windows - Python create exe file with pyinstaller

i write a program that detected and recognition visitors with face_recognition . i try to make exe file with pyinstaller .it's make .exe file but when i run the .exe it has an error.

E:python sourcepython examplesVisitorsdist>main_window.exe
Traceback (most recent call last):
  File "main_window.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "e:python sourcepython-3.9.1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 493, in exec_module
    def find_spec(self, fullname, path=None, target=None):
  File "face_recognition\__init__.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "e:python sourcepython-3.9.1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 493, in exec_module
    def find_spec(self, fullname, path=None, target=None):
  File "face_recognitionapi.py", line 20, in <module>
RuntimeError: Unable to open C:UsersSHAHRA~1AppDataLocalTemp\_MEI144802face_recognition_modelsmodelsshape_predictor_68_face_landmarks.dat
[13080] Failed to execute script main_window

my source code on github : "** https://github.com/shahram-arefhakimi/Visitors_with_PySide2 **"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have come through this issue previously and there is a solution to it. When you type this in the terminal (cmd or PowerShell):

pyinstaller --onefile -w filename.py

if you remove the

-w

so it is just

pyinstaller --onefile filename.py

then you will be able to run the exe fine

This will work 99% but if not, then there is a possibility that you have an error in your code


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...