【Python】pyinstaller打包運行報錯failed to execute script main


前言

最近用pyinstaller打包的時候一直報“failed to execute script main”。
最終使用“pyinstaller --hidden-import=pkg_resources -F main.py” 順利打包。
注意:語句中的“-F”一定要大寫

轉載原文

本文轉載自pyinstaller打包運行報錯failed to execute script main

pyqt5寫完win32 應用程序后,經過pyinstaller打包成單個文件,運行彈出錯誤提示框:failed to execute script main
pycharm中pyinstaller打包參數:
Program:C:\Python\Python35\Scripts\pyinstaller.exe
Parameters: -w -F $FileName$
Working directory: $FileDir$

分析:
經google,發現pyinstaller 有--hidden-import 選項
--hidden-import MODULENAME, --hiddenimport MODULENAME
Name an import not visible in the code of the
script(s). This option can be used multiple times.

解決:
打包時加上 --hidden-import=queue
即Parameters配置修改為:
Parameters:--hidden-import=queue -w -F $FileName$
eg:
pyinstaller --hidden-import=queue -w -F main.py

在其他地方看到這種用法,可以嘗試下,本人未驗證:pyinstaller --hidden-import=pkg_resources -F main.py


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM