安装
1.下载解压PyInstaller-2.1.zip,可以放在任意目录
2.cd C:\PyInstaller-2.1
执行python PyInstaller.py
若出现如下错误,则需要安装pywin32-218.win32-py2.7.exe
3.继续执行python PyInstaller.py
若出现以下现象,则成功
命令执行方式
方式一
cd C:\PyInstaller-2.1
执行python PyInstaller.py -F C:\Users\GYP\Desktop\test\test.py
其中C:\Users\GYP\Desktop\test\test.py是我要转换的那个测试文件,注意路径要写对!
红框里是生成文件的路径。找到该文件双击执行,就可以了。
加图标
C:\PyInstaller-2.1>python PyInstaller.py -F C:\Users\GYP\Desktop\test\test.py -i C:\Users\GYP\Desktop\test\1.ico
其中C:\Users\GYP\Desktop\test\test.py,C:\Users\GYP\Desktop\test\1.ico是我要转换的那个测试文件和要加的图标。
方式二(建议使用)
将测试文件夹放到PyInstaller-2.1.zip的解压目录,cmd进入到测试文件夹
cd C:\PyInstaller-2.1\test
加图标
结果
红框里是生成文件的路径。找到该文件双击执行,就可以了。
主要参数
-F, –onefile Py代码只有一个文件
-D, –onedir Py代码放在一个目录中(默认是这个)
-K, –tk 包含TCL/TK
-d, –debug 生成debug模式的exe文件
-w, –windowed, –noconsole 窗体exe文件(Windows Only)
-c, –nowindowed, –console 控制台exe文件(Windows Only)
-X, –upx 使用upx压缩exe文件
-o DIR, –out=DIR 设置spec文件输出的目录,默认在PyInstaller同目录
-icon= 加入图标(Windows Only)
-v FILE, –version=FILE 加入版本信息文件