1.官网http://www.pyinstaller.org/下载pyinstall,我下载了一个PyInstaller 2.0没用起来,哪位大神用起来了,在我下面留言哦(*^__^*),然后下载了pyinstaller-1.5.1.zip。
2.解压到你想解压的目录下。我解压到D:\pyinstaller-1.5.1
3.cmd 到 D:\pyinstaller-1.5.1 目录下,D:\pyinstaller-1.5.1>python Configure.py
4.D:\pyinstaller-1.5.1>makespec.py -F -w --icon=D:\aa.ico D:\aa.py
在D:\pyinstaller-1.5.1 目录下会生成aa的文件夹,里面有aa.spec文件,将它copy到aa.py同在的目录下。
5.D:\pyinstaller-1.5.1>build.py D:\aa.spec
在aa.py所在的目录下生成dist文件夹,里面有aa.exe文件。
Makespec.py的可用参数:
-F, --onefile | produce a single file deployment (see below). |
-D, --onedir | produce a single directory deployment (default). |
-K, --tk | include TCL/TK in the deployment. |
-a, --ascii | do not include encodings. The default (on Python versions with unicode support) is now to include all encodings. |
-d, --debug | use debug (verbose) versions of the executables. |
-w, --windowed, --noconsole | |
Use the Windows subsystem executable, which does not open the console when the program is launched. (Windows only) | |
-c, --nowindowed, --console | |
Use the console subsystem executable. This is the default. (Windows only) | |
-s, --strip | the executable and all shared libraries will be run through strip. Note that cygwin's strip tends to render normal Win32 dlls unusable. |
-X, --upx | if you have UPX installed (detected by Configure), this will use it to compress your executable (and, on Windows, your dlls). See note below. |
-o DIR, --out=DIR | |
create the spec file in directory. If not specified, and the current directory is Installer's root directory, an output subdirectory will be created. Otherwise the current directory is used. | |
-p DIR, --paths=DIR | |
set base path for import (like using PYTHONPATH). Multiple directories are allowed, separating them with the path separator (';' under Windows, ':' under Linux), or using this option multiple times. | |
--icon=<FILE.ICO> | |
add file.ico to the executable's resources. (Windows only) | |
--icon=<FILE.EXE,N> | |
add the n-th incon in file.exe to the executable's resources. (Windows only) | |
-v FILE, --version=FILE | |
add verfile as a version resource to the executable. (Windows only) | |
-n NAME, --name=NAME | |
optional name to assign to the project (from which the spec file name is generated). If omitted, the basename of the (first) script is used. |
常用参数:
-F 制作独立的可执行程序
-D 制作出的档案存放在同一个文件夹下(默认值)
-K 包含TCL/TK(对于使用了TK的,最好加上这个选项,否则在未安装TK的电脑上无法运行)
-w 制作窗口程序
-c 制作命令行程序(默认)
-X 制作使用UPX压缩过的可执行程序(推荐使用这个选项,需要下载UPX包,解压后upx.exe放在Python(非PyInstaller)安装目录下,下载upx308w.zip)
-o DIR 指定输出SPEC文件路径(这也决定了最后输出的exe文件路径)
--icon=[ICO文件路径] 指定程序图标
-v [指定文件] 指定程序版本信息
-n [指定程序名] 指定程序名称