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。

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