python 程序打包成exe

1.安裝py2exe軟件,軟件的版本應該和你Python的版本相同。

 下載地址:https://sourceforge.net/projects/py2exe/files/latest/download

2.在你要打包成exe的py文件目錄下寫一個實現打包py文件  setup.py


#setup.py  
from distutils.core import setup  
import py2exe  
setup(windows=[{"script": "SpiderTaskDistributor.py"}])  


SpiderTaskDistributor.py替換成你要打包的py文件。


3.在cmd下進入該目錄,執行python setup.py py2exe

4.打包py程序時,出現這個錯誤: error: MSVCP90.dll: No such file or directory

 

解決方法:

方法一:在網站 下載該文件http://www.dll-files.com/dllindex/dll-files.shtml?msvcp90

並拷貝在Python安裝目錄的DLLs即可。

方法二:

setup.py 中的setup設置爲:

setup(windows=["SpiderTaskDistributor.py"],options = { "py2exe":{"dll_excludes":["MSVCP90.dll"]}})

在該目錄下會生成dist文件夾,同時生成 pic.exe 雙擊pic.exe 即可運行程序,即使你沒有在該電腦安裝python。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章