类似pyinstaller_为什么在用pyinstaller和py2exe将py打包exe的时候报错?

在win10 64位系统和Python 3.6环境下,尝试使用py2exe打包时出现报错。错误源于Python 3.5之后generators属性的变化,导致py2exe的编译过程失败。降级到Python 3.4后问题解决,提示py2exe可能不兼容Python 3.5及以上版本。
摘要由CSDN通过智能技术生成

win10 64位,python 3.6 ,使用py2exe,完整的报错如下:

running py2exe

Traceback (most recent call last):

File "setup.py", line 24, in

options = {'py2exe': py2exe_options}

File "E:\Python\Python36\lib\distutils\core.py", line 148, in setup

dist.run_commands()

File "E:\Python\Python36\lib\distutils\dist.py", line 955, in run_commands

self.run_command(cmd)

File "E:\Python\Python36\lib\distutils\dist.py", line 974, in run_command

cmd_obj.run()

File "E:\Python\Python36\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run

self._run()

File "E:\Python\Python36\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run

builder.analyze()

File "E:\Python\Python36\lib\site-packages\py2exe\runtime.py", line 160, in analyze

self.mf.import_hook(modname)

File "E:\Python\Python36\lib\site-packages\py2exe\mf3.py", line 120, in import_hook

module = self._gcd_import(name)

File "E:\Python\Python36\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import

return self._find_and_load(name)

File "E:\Python\Python36\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load

self._scan_code(module.__code__, module)

File "E:\Python\Python36\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code

for what, args in self._scan_opcodes(code):

File "E:\Python\Python36\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes

yield "store", (names[oparg],)

IndexError: tuple index out of range

-----------------------------------------------------------------------------

把python回退到3.4之后,这个问题得到解决。

根据Python3.5的API变动说明,初步判断问题原因是 generators 在3.5之后的属性有变化,而 yield 的实现用到了 generator(了解很浅,如有误请指正)。

正好py2exe支持的最高版本为py3.4 。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值