欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python转成exe_将python程序转换成exe程序

发布时间:2025/3/20 python 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python转成exe_将python程序转换成exe程序 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

将python程序转换成exe.

一、 先安装python

2、安装下载包,一路next。

3、为计算机添加安装目录搭到环境变量,如图把python的安装目录添加到pth系统变量中即

可。(D:\\python32 是python的安装路径)

4、测试python安装是否成功,cmd打开命令行输入 python 命令,如下图即成功了

6、直接解压安装到python的安装目录即可,C:\Python27\pyinstaller (pyinstaller 就是解压后的目录

7、进入到安装pyinstaller的目录,新建一个存放py文件的目录,在新建的目录里放置我们的py程序

8、C:\Python27\PyInstaller-3.1.1

9、 转换成exe.

在命令行执行:python Makespec.py --console --onefile net\deploy_web.py

也许你会出现以下错误,也许不会,不报错直接第9步

报错:Configfile is missing or unreadable. Please run Configure.py before building

10、解决方法:

在命令行执行:Configure.py

报错:Python 2.6+ on Windows support needs pywin32,Please install http://sourceforge.net/projects/pywin32/

如果Python版本太低,则安装最新版本的 pywin32-217.win32-py2.7.exe,下载地址:http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/

无错误时候,继续执行上 第9步

关于-F 参数解释:

-F, --onefile

create a single file deployment

-D, --onedir

create a single directory deployment (default)

-o DIR, --out=DIR

create the spec file in directory. If not specified, and the current directory is Installer’s root directory, an output subdirectory will be created. Otherwise the current directory is used.

-n NAME, --name=NAME

optional name to assign to the project (from which the spec file name is generated). If omitted, the basename of the (first) script is used.

11、成功后生成一个和py脚本同名的目录(deploy_web),在dict目录下就生成一个.exe 程序。

12、执行完.exe程序后生成一个txt文件,里面就是想要的信息、

总结

以上是生活随笔为你收集整理的python转成exe_将python程序转换成exe程序的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。