如何在PyInstaller中指定.spec文件?

9 投票
2 回答
26128 浏览
提问于 2025-04-18 06:12

我该如何在使用PyInstaller编译我的.py文件时,指定.spec文件,同时使用--onefile--noconsole选项呢?

2 个回答

8

PyInstaller 会生成一个 .spec 文件。你可以先用它来处理你的单文件应用,然后在以后的运行中引用你编辑过的 .spec 文件。

  • 使用单文件应用:

    pyinstaller main.py

    注意:这会覆盖 main.spec 文件,所以以后不要再用这个命令了

  • 使用 .spec 文件:

    pyinstaller main.spec

8

试试这样做:

C:\Python27\python.exe C:\Python27\Lib\site-packages\PyInstaller\main.py --onefile  --noconsole main.spec

撰写回答