1. 程式人生 > >python3.6.1 打包成.exe可執行檔案

python3.6.1 打包成.exe可執行檔案

環境:

python3.6.1 win10

1、下載pyinstaller.
2、下載並安裝pywin32 (根據自己的python版本我的對應版本pywin32-220.win-amd64-py3.6.exe)
3、進入pyinstaller資料夾
執行 python pyinstaller.py會出現以下內容,說明安裝成功
這裡寫圖片描述
4、打包,選好自己的寫的一個python程式( 例如hello.py),將他放到pyinstaller目錄下,然後執行以下命令:

pyhton pyinstaller.py -F hello.py

會生成一個hello資料夾,所打包好的exe檔案就在dist目錄下。

注:其中需要注意的幾個問題。
1、當報錯ImportError: No module named pefile
安裝這個模組就好
2、IndexError:tuple index out of range錯誤
https://github.com/pyinstaller/pyinstaller重新下載原始碼即可