用Pyinstaller打包发布exe应用

pyinstaller(http://www.pyinstaller.org/) 先去官网看支持的python版本

#安装方法1

pip install pyinstaller   (会自动下载future,pywin32,pyinstaller)

1.cmd到/python/scripts 找到pyinstaller.exe
2.输入命令

1
pyinstaller.exe -F path:demo.py

 

后记:

1.程序设置自定义图标:pyinstaller -F -i ico_path  py_path 

首先需要下载一张正常的ico,不能用直接修改后缀的。

下载图片:    https://www.easyicon.net

图片改为ico:  http://www.ico.la/

输入命令 pyinstaller -F -i "demo.ico" "main.py"

2.报错提示:

pyinstaller -F -i "demo.ico" "main.py" 命令格式一定是先图标路径,再程序路径。

路径最好为英文,没有中文字符;脚本名称里没有特殊字符如 .

使用utf8编码

图标文件必须是正常格式,不能直接更改后缀。

tuble index out of range ---》pyinstaller版本尚未支持python的版本

3.窗口程序

使用 pyinstaller -F -w  -i ico_path  py_path ,这样脚本不会弹出命令窗,前提是用了GUI库. 

4.导入模块问题

pyinstaller -F -w  -i  --hidden-import queue ico_path  py_path 加上选项

猜你喜欢

转载自blog.csdn.net/u014024839/article/details/80594056