python文件打包成exe可执行文件出错。
Python 3.10.0
PyInstaller 5.1
官方文档说PyInstaller已经支持3.7之后的python版本,但在运行过程中还是遇到,IndexError: tuple index out of range问题。
解决办法:
编辑python3\Lib下的dis.py文件。
找到def _unpack_opargs(code)函数,在else语句中添加extended_arg=0,如下图所示。
在命令行输入命令,-F代表打包成一个exe文件,-c是命令行脚本。
pyinstaller -F -c test.py
已经打包成功了,dist文件夹中生成了一个exe文件。