当前位置: 移动技术网 > IT编程>脚本编程>Python > 详解Python3.6的py文件打包生成exe

详解Python3.6的py文件打包生成exe

2019年06月16日  | 移动技术网IT编程  | 我要评论

cf聊天,海安实验中学,会计英语

原文提到的要点:

1. python版本32位 (文件名为 python-3.6.1.exe)

2. 安装所有用到的模块(原文博主用的是openpyxl,我用到的有urllib中的request\config\data)

3. 下载替换pyinstaller(下载pyinstaller-develop.zip,复制其中的pyinstaller文件夹)

4. 在控制台生成exe

操作过程记录如下:

c:\python\scripts>pip install request
c:\python\scripts>pip install config
c:\python\scripts>pip install data
c:\python\scripts>pyinstaller.exe -f structs2.py

生成成功界面内容:

24957 info: checking exe
24957 info: building exe because out00-exe.toc is non existent
24957 info: building exe from out00-exe.toc
24958 info: appending archive to exe c:\python\scripts\dist\structs2.exe
24975 info: building exe from out00-exe.toc completed successfully.

之前失败了很多次,python 3 转 exe 失败原因总结:

1. python开发环境版本、环境变量不一致。之前错误的安装了(python-3.6.2rc1.exe)

2. 注意版本,之前尝试了多个版本,最后全部卸掉重新安装才成功

3. python包要安装全,之前我没有装request \config等包,也可能是失败原因之一

曾有失败,内容如下:

usage: setup.exe [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.exe --help [cmd1 cmd2 ...]
or: setup.exe --help-commands
or: setup.exe cmd --help

解决方法是重新清理安装开发环境。终于成功。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网