pyinstaller---3步即可将你的py文件转成exe格式
来源:互联网 发布:名模a穆雅斓的淘宝真假 编辑:程序博客网 时间:2024/06/05 09:26
首先要注意一下:打包python文件成exe格式这个过程只能在windows环境下运行
1. 直接在命令行用pip安装 pyinstaller
pip install pyinstaller
2. 下载安装pyinstaler运行时所需要的windows拓展---pywin32
pywin32:http://sourceforge.net/projects/pywin32/files/pywin32/
点击最新的Build
再点击pywin32-219.win-amd64-py2.7.exe
(这里要根据你的windows x86或者x64和你的python版本来选择)
3.在命令行中切换到要打包的程序所在目录,直接输入下面的指令即可
pyinstaller -F demo.py
-F
指定打包后只生成一个exe格式的文件-D
–onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项)-c
–console, –nowindowed 使用控制台,无界面(默认)-w
–windowed, –noconsole 使用窗口,无控制台-p
添加搜索路径,让其找到对应的库。-i
改变生成程序的icon图标注意事项:
- 生成文件中,可能包含一个以warn开头的类似warndemo.txt的警告文件
这很明显,是因为程序无法自动导入很多的库
使用-p
参数添加搜索路径
pyinstaller.py -F -p C:\python27; ..\demo.py #注意当前目录是我在下一级目录里
2.添加icon图标
pyinstaller.py -F -p C:\python27; -i ..\a.ico ..\demo.py
对了,这里有个网址可以参考一下
后话:
我按照自己写的步骤在自己电脑上试了一下是可以的,但是将exe拷贝到别人电脑上用了一下,发现出了一个这样的错误
F:\qq文件\a>AutoRecord.exeTraceback (most recent call last): File "<string>", line 21, in <module> File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 507, in install File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 156, in __init__ImportError: Can't load frozen modules.
这个问题是因为他的运行目录里面包含了中文,要处理中文要从github上面安装最新的pyinstaller
git clone https://github.com/dkw72n/pyinstaller.gitpython setup.py install
然后重新打包.py文件再次发给对方就可以解决这个问题了
解决一些问题可以查看这个网址使用PyInstaller打包Python程序
我一般用的步骤,首先进入到pyinstall.py的目录
D:\Program Files (x86)\Python>cd PyInstaller-3.2.1
-F可以编译成EXE
-i可以改变图标
-w可以去掉命令窗口
一般步骤
D:\Program Files (x86)\Python\PyInstaller-3.2.1>python pyinstaller.py -F -i snow.ico -w rub.py
阅读全文
1 0
- pyinstaller---3步即可将你的py文件转成exe格式
- pyinstaller---3步即可将你的py文件转成exe格式
- pyinstaller(py文件转成exe)
- pyinstaller--将py文件转化成exe
- 如何将PY文件转成EXE文件
- 用PyInstaller将.py文件打包成.exe文件
- pyInstaller 将python文件.py转换为windows可执行文件.exe的标准化方法
- 用PyInstaller将依赖Dlib库的python文件(.py)转换成exe可执行文件
- 使用pyinstaller将py变成exe
- Python菜鸟晋级12----用pyinstaller将.py文件打包成.exe执行文件
- Python进阶(四十七)-python3使用pyinstaller实现将py文件打包成exe文件
- pyinstaller.exe打包.py文件成exe文件
- 将java转成exe文件的方法
- 使用Pyinstaller将.py程序转换为.exe程序
- 用PyInstaller将python转成可执行文件exe笔记
- 用PyInstaller将python转成可执行文件exe笔记
- 用PyInstaller将python转成可执行文件exe笔记
- 使用pyinstaller把py文件打包为exe文件
- Cordova入门篇:(一) IDEA+Cordova运行第一个项目
- nvm工具
- Kotlin 踩坑日记(五)aapt2 编译 bug
- numpy 随机数种类np.random.RandomState、np.random.rand、np.random.random、np.random_sample
- Tomcat启动时SecureRandom超级慢的问题
- pyinstaller---3步即可将你的py文件转成exe格式
- 图片预加载1
- python | append( ) & extend( )的区别
- mycat 启动服务是报错 The Mycat-server service was launched, but failed to start.解决方案
- Spring Bean装配--@Bean注解注入说明
- jQuery placeholder, fix for IE6,7,8,9
- 《道德经》第二十四章
- 实习面经-百度运维部
- 洛谷日记6