一、環境
windows 10 x64
python 3.6.6 x64
二、安裝pyinstaller
pip install pyinstaller
三、基本用法
pyinstaller hello.py
四、常用參數
-F 表示生成單個可執行文件(盡量不使用,打包成單個文件后,程序啟動時間較長)
-w 表示去掉控制台窗口
-p 表示你自己自定義需要加載的類路徑(如果有多個文件需要加這個參數,還可以指定site-packages路經)
-i 表示可執行文件的圖標(這個對圖標格式有要求,之前一直不起作用,換了張64x64 ico圖標就行了)
五、常見問題
5.1、python3.7使用pyinstaller 不能正常運行
Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x000011c0 (most recent call first):
看到stackouerflow上說 pyinstaller 目前對python3.7支持不好,推薦使用python3.3 ~ python 3.6
重新安裝python3.6在打包就可以了


