參考:http://pythonhosted.org/PyInstaller/#installing-pyinstallerpython
一、下載pyinstaller和PyWin32 ui
目前pyinstaller支持的python版本爲2.3-2.7,能夠到http://www.pyinstaller.org/官網下載。注意PyWin32 對應不太的python版本this
二、安裝spa
pyinstaller下載完成後,解壓便可。PyWin32 安裝.net
三、pyinstaller使用方法code
使用也很是的簡單,cmd下進入解壓出來的目錄,進入當前目錄,比方說解壓到d:/pyinstaller/,執行中間件
方法一:當前目錄下沒有spec文件,執行
python pyinstaller.py [opts] yourprogram.py
方法一:當前目錄下有spec文件,執行
python pyinstaller.py [opts] your-program.spec
4 主要選項包括:ip
Allowed OPTIONS are:
-h, --help show this help message and exit
-v, --version show program version
--upx-dir=UPX_DIR Directory containing UPX.
-a, --ascii do NOT include unicode encodings (default:
included if available)
--buildpath=BUILDPATH Buildpath (default:
SPECPATH/build/pyi.TARGET_PLATFORM/SPECNAME)ci
-y, --noconfirm Remove output directory (default:
SPECPATH/dist/SPECNAME) without
confirmation
--log-level=LOGLEVEL Log level (default: INFO, choose one of DEBUG,
INFO, WARN, ERROR, CRITICALunicode
What to generate:
-F, --onefile create a single file deployment
-D, --onedir create a single directory deployment (default)
-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.
-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, –onefile 打包成一個exe文件。
-D, –onedir 建立一個目錄,包含exe文件,但會依賴不少文件(默認選項)。
-c, –console, –nowindowed 使用控制檯,無界面(默認)
-w, –windowed, –noconsole 使用窗口,無控制檯
具體參考PyInstaller安裝目錄下的PyInstaller Manual