如何将python文件打包成exe格式

1、安装pyinstaller

打开命令行,安装pyinstaller模块

pip install pyinstaller

image-20211217220823007

若出现如下图所示的无法连接HTTPS的问题请参考文章:成功解决win10下 Can’t connect to HTTPS URL because the SSL module is not available

image-20211217220957438

查看是否安装成功

pip list

image-20211217221137743

2、进入python文件的存储位置

看自己的保存路径

image-20211217221256470

3、生成exe文件

执行命令

pyinstaller -F tree.py(要打包的脚本文件)

image-20211217222422342

执行完成之后会新增如下图所示的文件

image-20211217221530727

而我们所需要的exe文件就在dist文件夹下面

image-20211217221717967

点击就可以运行了

4、pyinstaller详解

Pyinstaller -F tree.py 打包exe
 
Pyinstaller -F -w tree.py 不带控制台的打包
 
Pyinstaller -F -w -i tree.ico tree.py 打包指定exe图标打包

image-20211217222247932

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐