用Pyinstaller打包时出现IndexError怎么回事?

发布于 2022-09-04 21:17:07 字数 3849 浏览 35 评论 0

在我的package里面有个game.py写好的,然后用pyinstaller打包就出现了下面的情况:

C:\package>pyinstaller -F game.py
166 INFO: PyInstaller: 3.2.1
166 INFO: Python: 3.6.1
166 INFO: Platform: Windows-10-10.0.14393-SP0
166 INFO: wrote C:\package\game.spec
182 INFO: UPX is not available.
182 INFO: Extending PYTHONPATH with paths
['C:\\package', 'C:\\package']
182 INFO: checking Analysis
182 INFO: Building Analysis because out00-Analysis.toc is non existent
182 INFO: Initializing module dependency graph...
199 INFO: Initializing module graph hooks...
202 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "C:\Python36\Scripts\pyinstaller-script.py", line 11, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\building\build_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\building\build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\building\build_main.py", line 212, in __init__
    self.__postinit__()
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\building\datastruct.py", line 161, in __postinit__
    self.assemble()
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\building\build_main.py", line 317, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
    graph.import_hook(m)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
    source_package, target_module_partname, level)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_p
ackage
    target_module_headname, target_package_name, source_package)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import
_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module

    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
    module, module_code_object, is_scanning_imports=False)
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_byteco
de
    global_attr_name = get_operation_arg_name()
  File "C:\Python36\lib\site-packages\pyinstaller-3.2.1-py3.6.egg\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operatio
n_arg_name
    return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range

Traceback显示应该不是我的game.py的问题。请问这是怎么了?
安装的是最新版的pyinstaller3.2.1版本,Python是3.6版本的。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

弥繁 2022-09-11 21:17:07

Python 3.6: IndexError: tuple index out of range, 上面提到

RTFM: PyInstaller 3.2.1 does not support Python 3.6

也就是pyinstaller3.2.1不支持Python 3.6.

一世旳自豪 2022-09-11 21:17:07

建议pyinstaller不要用最新的python版本,至少python3.5以下版本是可行的。

瞄了个咪的 2022-09-11 21:17:07

支持3.6的还没有放出,但是可以手动安装
https://github.com/pyinstalle... 下载zip后把PyInstaller提出来。删掉python/Lib/site-packages/PyInstaller 文件夹,把解压得到的PyInstaller放进去应该就OK了。#_#

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文