使用 pyinstaller
打包 py 脚本
- 到 github 下载
pyinstaller
Windows 平台下载 zip,解压。 - 切换到目录, 运行
python setup.py install
开始安装。 - 切换到要打包的程序目录
pyinstaller -F test.py
。(-F 打包成单文件 运行会很慢,但是简洁)
Problem1
RecursionError: maximum recursion depth exceeded
解决方案
找到*.spec
文件,在第二行添加
import sys
sys.setrecursionlimit(5000) # or more
执行pyinstaller test.spec
参考文献: pyinstaller and matplotlib gets maximum recursion depth exceeded
Problem 2
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 110: invalid continuation byte
解决方案
控制台输入chcp 65001
将 cmd 切换至 utf-8 编码,重新运行pyinstaller test.spec
安装成功