python生成可執行exe

2021-08-21 05:38:24 字數 905 閱讀 2145

1,打2015 補丁

例如,pip install matplotlib, pip install opencv-python,

pip install scikit-learn

pip install pyinstaller

編譯分兩步

第一,pyinstaller -f  x.py , 會在同目錄下產生x.spec 檔案;

第二,等第一步結束後,開啟x.spec檔案,將其中的  datas, 和hiddenimports替換為:          

datas=[('model\\','model')],

hiddenimports=['scipy._lib.messagestream', 'sklearn.neighbors.typedefs'],

然後,執行 pyinstaller -f x.spec

最終生成的exe 在dist下面,拿出來放到x.py同目錄下,即可執行

打包可能遇到的問題:

1.pyinstaller unicodedecodeerror: 『utf-8』 codec can』t decode byte 0xce in position 110: invalid continuation byte

解決辦法:

修改d:\python35\lib\site-packages\pyinstaller\compat.py檔案中

out=out.decode(encoding)為:

out=out.decode(encoding, errors='ignore')

Python生成exe可執行檔案

f 表示生成單個可執行檔案 d onedir 建立乙個目錄,包含exe檔案,但會依賴很多檔案 預設選項 w 表示去掉控制台視窗,這在gui介面時非常有用。不過如果是命令列程式的話那就把這個選項刪除吧!c console,nowindowed 使用控制台,無介面 預設 p 表示你自己自定義需要載入的類...

Python如何生成可執行的 exe檔案

為什麼要生成可執行檔案 不需要安裝對應的程式設計環境 可以將你的應用閉源 使用者可以方便 快捷的直接使用 打包工具 pyinstaller 一.pyinstaller簡介 python是乙個指令碼語言,被直譯器解釋執行。它的發布方式 py檔案 對於開源專案或者原始碼沒那麼重要的,直接提供原始碼,需要...

python檔案生成exe可執行檔案

一般情況下使用以下指令即可。pyinstaller f w pypyinstaller指令有一些常見的引數,如下表所示 可選引數 格式舉例 功能說明 f pyinstaller f py 只在dist中生產乙個 exe檔案。d pyinstaller d py 預設選項,除了 exe外,還會在在di...