可以使用pyinstaller为所需的不同平台创建可执行文件。
例如
pyinstaller命令的语法为:pyinstaller [options] script [script ...] | specfile
在最简单的情况下,将当前目录设置为程序myscript.py的位置并执行:pyinstaller myscript.py
PyInstaller分析myscript.py和:Writes myscript.spec in the same folder as the script.
Creates a folder build in the same folder as the script if it does not exist.
Writes some log files and working files in the build folder.
Creates a folder dist in the same folder as the script if it does not exist.
Writes the myscript executable folder in the dist folder.
在dist文件夹中,可以找到分发给用户的捆绑应用程序。
通常在命令行中命名一个脚本。如果您指定更多,所有的都将被分析并包含在输出中。但是,名为的第一个脚本提供规范文件和可执行文件夹或文件的名称。它的代码是第一个在运行时执行的。
对于某些用途,您可以编辑myscript.spec的内容(在“使用规范文件”下介绍)。执行此操作后,将规范文件命名为PyInstaller,而不是脚本:pyinstaller myscript.spec
您可以给出脚本或规范文件的路径,例如pyinstaller options... ~/myproject/source/myscript.py
或者,在窗户上pyinstaller "C:\Documents and Settings\project\myscript.spec"