Pyinstaller(python打包为exe文件)
2018-02-03 11:10
211 查看
需求分析:
python脚本如果在没有安装python的机器上不能运行,所以将脚本打包成exe文件,降低脚本对环境的依赖性,同时运行更加迅速。
当然打包的脚本似乎不是在所有的win平台下都能使用,win7有一部分不能使用,我在win10能够很好的运行。
准备:
pyinstaller(http://www.pyinstaller.org/) 首先还是去官网看支持的python版本,不然会很尴尬的
#安装方法1:
#安装pyinstaller和pywin32
#使用一下命令将自动安装两个包,在cmd用pip命令
#pip install -i https://pypi.douban.com/simple/ pyinstaller(豆瓣源)
安装方法二:
pip install pyinstaller (会自动下载future,pywin32,pyinstaller)
如何使用Pyinstaller
方法一:
1.cmd到/python/scripts 找到pyinstaller.exe
2.输入命令
方法二:
1.进入pyinstaller的解压包,输入命令
2."python pyinstaller.py -F path:demo.py"
从cmd最后一行输出可查找到生成的文件
后记:
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 加上选项
python脚本如果在没有安装python的机器上不能运行,所以将脚本打包成exe文件,降低脚本对环境的依赖性,同时运行更加迅速。
当然打包的脚本似乎不是在所有的win平台下都能使用,win7有一部分不能使用,我在win10能够很好的运行。
准备:
pyinstaller(http://www.pyinstaller.org/) 首先还是去官网看支持的python版本,不然会很尴尬的
#安装方法1:
#安装pyinstaller和pywin32
#使用一下命令将自动安装两个包,在cmd用pip命令
#pip install -i https://pypi.douban.com/simple/ pyinstaller(豆瓣源)
安装方法二:
pip install pyinstaller (会自动下载future,pywin32,pyinstaller)
如何使用Pyinstaller
方法一:
1.cmd到/python/scripts 找到pyinstaller.exe
2.输入命令
1.进入pyinstaller的解压包,输入命令
2."python pyinstaller.py -F path:demo.py"
从cmd最后一行输出可查找到生成的文件
12468 INFO: Appending archive to EXE D:\Documents\Downloads\PyInstaller-3.2\down load\dist\download.exe
后记:
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 加上选项
相关文章推荐
- 用PyInstaller把Python代码打包成单个独立的exe可执行文件
- 使用pyinstaller打包python为exe文件
- 使用pyinstaller工具打包python项目代码生成exe文件
- Python 3.6 使用 pyinstaller 打包exe文件遇到的问题
- 如何利用Python2.7、py2exe、PyInstaller-2.1将*.py打包成*.exe,再利用Inno Setup Compiler封装成windows安装文件
- [置顶] Python进阶(四十七)-python3使用pyinstaller实现将py文件打包成exe文件
- PyInstaller 打包 Python 源码为 exe 可执行文件
- 11 Python pyinstaller--将Python程序打包成单独的exe可执行文件
- 用pyinstaller把python代码打包成exe可执行文件
- 使用PyInstaller将Python程序打包成一个单独的exe文件
- 使用pyinstaller打包python为exe文件
- pyinstaller 打包python程序为.exe文件
- 【转载】用PyInstaller把Python代码打包成单个独立的exe可执行文件
- 使用pyinstaller工具打包python项目代码生成exe文件
- “failed to excute script xxx” PyInstaller 打包python程序为exe文件过程错误
- 使用pyinstaller工具打包python项目代码生成exe文件
- py库:把python打包成exe文件(pyinstaller)
- 利用pyinstaller将Python3.6文件打包成exe程序
- Python3之使用pyinstaller打包.py文件成exe可执行文件
- Python程序用pyinstaller打包成exe文件