使用pyinstaller生成exe
<div id="cnblogs_post_body">1.下载安装pyinstallerhttp://www.pyinstaller.org/
解压到任意位置即可。
2.编译配置环境
进入pyinstaller解压目录,运行 python Configure.py
*(可能需要安装pywin32.下载并安装即可,重新运行 python Configure.py)
3.生成spec
进入pyinsaller解压目录
运行 python Makespec.py --onefile yourprogram.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.
4.编译spec文件
还是当前目录,运行
python Build.py specfile
5.在dist目录下即可找到exe文件
6.参考官方文档
http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html?format=raw
页:
[1]