參考: http://pythonhosted.org/PyInstaller/#installing-pyinstaller
1、下載pyinstaller和 PyWin32 ?
目前pyinstaller支持的python版本為2.3-2.7,可以到http://www.pyinstaller.org/官網下載。注意 PyWin32 ?對應不太的python版本
2、安裝
pyinstaller 下載完成后,解壓即可。 PyWin32 ?安裝
3、pyinstaller使用方法
使用也非常的簡單,cmd下進入解壓出來的目錄,進入當前目錄,比方說解壓到d:/pyinstaller/,執行
方法一:當前目錄下沒有spec文件,執行
python pyinstaller.py [opts] yourprogram.py
- 方括號[]里面為可選項,
- 執行目錄后,在d:/pyinstaller/目錄里面生成一個your-program/dist子目錄,你有用的文件就放在這里了,
- 同時生成一個your-program/your-program.spec文件
- 同時生成一個your-program/build,里面存放buid文件(中間件)
- 如果程序不在“d:/pyinstaller/”里面,指定程序的路徑,spec,dist,buid目錄文件將在當前目錄下生成
方法一:當前目錄下有spec文件,執行
python pyinstaller.py [opts] your-program.spec
4 主要選項包括:
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)
-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, CRITICAL
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
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
