pyinstaller 下載地址:http://www.pyinstaller.org/python
下載後用cmd進入解壓文件夾 python setup.py install 安裝。小程序
最近用pyinstaller打包小程序,遇到一些問題。get
1.用最新版本的pyinstaller3.2打包時,出現錯誤:ImportError: No module named ‘pefile’。input
解決方法:安裝了pyinstaller3.0cmd
2.打包時閃退console
問題:程序有錯誤,將打包好的exe文件拖至cmd裏面運行,就能夠看到報錯提示,改正。module
若是程序沒有錯誤,則在末尾加入 raw_input()打包
pyinstaller 使用方法:file
1.將要打包的程序以及.ico後綴的圖標放到同一個文件夾中。搜索
2.cmd進入安裝pyinstaller的文件夾中,運行語句:
[pyinstaller.py -F -i F:\program\temp\example.ico F:\program\temp\example.py]
則在安裝pyinstaller的文件夾中,有一個example命名的文件夾,dist子文件夾裏就存在打包好的程序。
其中參數含義以下:
-F 指定打包後只生成一個exe格式的文件
-c –console, –nowindowed 使用控制檯,無界面(默認)
-w –windowed, –noconsole 使用窗口,無控制檯
-p 添加搜索路徑,讓其找到對應的庫。
-i 改變生成程序的icon圖標