.py到.exe发行

时间:2019-03-01 15:13:05

标签: python pyinstaller

我对pyinstaller有问题;我有python文件(Main_w_PyQt5.py),该文件使用三张图片(kepler.png; keplerII.png和kepler.ico)。我将pyinstaller与以下参数一起使用:

pyinstaller --onefile --noconsole --icon='kepler.ico' --add-data='kepler.png;.' --add-data='keplerII.png;.' --clean Main_w_PyQt5.py

.exe文件的效果很好,直到我想通过调用退出函数将其关闭为止,弹出的窗口显示“无法执行Main_w_PyQt5.py”。

这是什么问题?

1 个答案:

答案 0 :(得分:0)

my (confirmed) comment处获得答案:

请勿使用exit。根据文档,它仅可用于交互式解释器(not even guaranteed to exist since the site module is optional):

  

[这些函数/常量]对于交互式解释器外壳很有用,不应在程序中使用。

使用sys.exitwhich is the correct way to signal your intent to exit a script

人们会变得懒惰并使用exit,因为它恰好可以在大多数简单的脚本环境中工作,但是PyInstaller至少不是那么简单,并且使用它会引起问题。

相关问题