日期:2018年08月15日python
嘗試如下將py文件打包成(假設你的文件是script.py,以windows平臺爲例,–onefile 是一種options)linux
pyinstaller options script.py
生成的可執行文件位於dist
目錄下,嘗試運行script.exe,若可正常運行,萬事大吉,結束。git
許多錯誤都是由 scipy
引起github
若提示缺乏scipy._lib.messagestream
,解決方法以下:web
(1)首先生成中間文件.spec(上一步已經生成過了,能夠不生成)shell
pyi-makespec options script.py
(2)打開.spec
文件windows
找到hiddenimports
,將其後的空列表[]
改爲 ['scipy._lib.messagestream']
,保存。svg
(3)從 .spec
編譯文件3d
pyinstaller option script.spec
打包成一個exe ( option: - - onefile)可執行文件當然方便,有時候也會引起莫名其妙的dll缺失的問題,若此問題出現了,把 - -onefile這個選項刪掉就好,此時,可執行文件爲dist/script/script.exe 。code
參考文檔
pyinstaller簡潔教程
官方文檔