.py to exe

1. 当然要先安装环境,点击这里找到py2exe.exe,下载下来安装!注意要找对应于你所安装的python版本。
2. 下载GUI2EXE这个文件, 安装之

3. 打开Gui2Exe, 配置好文件路径,exe类型等之后点击【Compile】

4. 编译后会自动生成build和dist两个文件夹,生成的exe文件在dist文件夹中,build文件夹中是中间文件,现在就没有用了。
5. 把dist文件夹ctrl+c/v到目标机器上即可执行exe了
-----------------------------------------
可能遇到的问题:
1. 编译的时候报错:
DeprecationWarning: the sets module is deprecated import sets
解决方法:

修改  C:\Python26\lib\site-packages\py2exe\build_exe.py

中的 import sets  为 #import sets;

然后全文替换 sets.Set() 为 set();

2. 执行exe的时候报错:
This application has failed to start because the application configuration is incorrect 。。。
这个错误是因为目标机器上的C Runtime Lib没有正确安装,可以到MS的官网上下载VC 发行包,安装后即可正常运行exe




原文地址:https://www.cnblogs.com/rickiedu/p/1540544.html