1. 程式人生 > >使用pyinstaller將py檔案打包成exe可執行程式

使用pyinstaller將py檔案打包成exe可執行程式

注:博主使用的 python3.5.3版本。

1. 下載安裝 pyinstaller包。

在終端中,cd到 python目錄下的 Scripts目錄內。

使用pip命令下載安裝 pyinstaller。

等待安裝完成。

2. 用 pyinstaller打包py檔案 

在終端中輸入 pyinstaller -F XXX.py。

等待打包完成,提示有.exe檔案生成。

3. 可能會出現編碼問題

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 168: illegal multibyte sequence 

附上解決辦法:

(1)進入 python目錄內的 Lib\site-packages\PyInstaller\utils\win32目錄裡,開啟 winmanifest檔案。

(2)開啟 winmanifest檔案,找到第1075行。

(3)把 with open(filename) as f:改為 with open(filename,encoding = 'UTF-8') as f: