Pyinstaller: IndexError: tuple index out of range

使用Python3.10时,Pyinstaller出现IndexError: tuple index out of range错误,部分异常信息如下:

.......
    yield from get_instructions(code_object)
  File "C:\Program Files\Python\lib\dis.py", line 338, in _get_instructions_bytes
    argval, argrepr = _get_const_info(arg, constants)
  File "C:\Program Files\Python\lib\dis.py", line 292, in _get_const_info
    argval = const_list[const_index]
IndexError: tuple index out of range

解决办法

修改C:\Program Files\Python\lib\dis.py文件,找到_unpack_opargs函数,在倒数第二行中添加extended_arg = 0即可,修改后的代码如下:

def _unpack_opargs(code):
    extended_arg = 0
    for i in range(0, len(code), 2):
        op = code[i]
        if op >= HAVE_ARGUMENT:
            arg = code[i+1] | extended_arg
            extended_arg = (arg << 8) if op == EXTENDED_ARG else 0
        else:
            arg = None
            extended_arg = 0  # +
        yield (i, op, arg)

参考链接:Tuple index out of range with Python 3.10 and pyinstaller 5.0.dev0 · Issue #6301 · pyinstaller/pyinstaller · GitHub

版权声明:本文为「txfly」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://www.jianshu.com/p/971141201105

你可能感兴趣的:(Pyinstaller: IndexError: tuple index out of range)