一、环境
windows 10 x64
python 3.6.6 x64
二、安装pyinstaller
pip install pyinstaller
三、基本用法
pyinstaller hello.py
四、常用参数
-F 表示生成单个可执行文件(尽量不使用,打包成单个文件后,程序启动时间较长)
-w 表示去掉控制台窗口
-p 表示你自己自定义需要加载的类路径(如果有多个文件需要加这个参数,还可以指定site-packages路经)
-i 表示可执行文件的图标(这个对图标格式有要求,之前一直不起作用,换了张64x64 ico图标就行了)
五、常见问题
5.1、python3.7使用pyinstaller 不能正常运行
Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x000011c0 (most recent call first):
看到stackouerflow上说 pyinstaller 目前对python3.7支持不好,推荐使用python3.3 ~ python 3.6
重新安装python3.6在打包就可以了