python3.7使用py2exe生成exe时报错 IndexError

目前py2exe支持的最新Python版本是3.6,3.7使用py2exe时会报错

  File "C:\Users\Minhaj\AppData\Local\Programs\Python\Python37-32\lib\site-packa
ges\py2exe\mf3.py", line 388, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Users\Minhaj\AppData\Local\Programs\Python\Python37-32\lib\site-packa
ges\py2exe\mf3.py", line 417, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range

可使用pyinstaller来打包,使用方法:

1

下载安装pyinstall,地址http://www.pyinstaller.org/downloads.html
(或者直接pip安装)

2

打开cmd,输入命令:pyinstaller -F 要打包的文件

3

打包成功后在pyinstaller文件目录下就会生成一个dist文件夹(cmd窗口会显示exe文件的位置),打开后就可以看到对应的.exe文件了

参考:
https://stackoverflow.com/questions/51503607/python-3-7-returns-indexerror-tuple-index-out-of-range-when-using-py2exe
https://blog.csdn.net/iku5200/article/details/83624345

发布了5 篇原创文章 · 获赞 3 · 访问量 4577

猜你喜欢

转载自blog.csdn.net/xiaoz2008/article/details/85481378