Pyinstaller和py2exe导致错误:"元组索引超出范围" [英] Pyinstaller and py2exe result in error: "tuple index out of range"

查看:22
本文介绍了Pyinstaller和py2exe导致错误:"元组索引超出范围"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次使用Pyinstaller,所以请原谅我。为什么以下内容会导致错误?我怎么才能修好它。我正在尝试将我编写的python程序转换为Windows.exe。

C:WINDOWSsystem32>pyinstaller C:UsersevankDesktopPackageprogram.py
121 INFO: PyInstaller: 3.2.1
121 INFO: Python: 3.6.1
121 INFO: Platform: Windows-10-10.0.15063-SP0
127 INFO: wrote C:WINDOWSsystem32program.spec
127 INFO: UPX is not available.
129 INFO: Extending PYTHONPATH with paths
['C:\Users\evank\Desktop\Package', 'C:\WINDOWS\system32']
129 INFO: checking Analysis
131 INFO: Building Analysis because out00-Analysis.toc is non existent
131 INFO: Initializing module dependency graph...
138 INFO: Initializing module graph hooks...
140 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "C:Program FilesPython36Scriptspyinstaller-script.py", line 11, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "c:program filespython36libsite-packagesPyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:program filespython36libsite-packagesPyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:program filespython36libsite-packagesPyInstalleruildinguild_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:program filespython36libsite-packagesPyInstalleruildinguild_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "c:program filespython36libsite-packagesPyInstalleruildinguild_main.py", line 212, in __init__
    self.__postinit__()
  File "c:program filespython36libsite-packagesPyInstalleruildingdatastruct.py", line 161, in __postinit__
    self.assemble()
  File "c:program filespython36libsite-packagesPyInstalleruildinguild_main.py", line 317, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "c:program filespython36libsite-packagesPyInstallerdependanalysis.py", line 560, in initialize_modgraph
    graph.import_hook(m)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 1509, in import_hook
    source_package, target_module_partname, level)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 1661, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "c:program filespython36libsite-packagesPyInstallerdependanalysis.py", line 209, in _safe_import_module
    module_basename, module_name, parent_package)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 2077, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 2167, in _load_module
    self._scan_code(m, co, co_ast)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 2585, in _scan_code
    module, module_code_object, is_scanning_imports=False)
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 2831, in _scan_bytecode
    global_attr_name = get_operation_arg_name()
  File "c:program filespython36libsite-packagesPyInstallerlibmodulegraphmodulegraph.py", line 2731, in get_operation_arg_name
    return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range

编辑:使用py2exe也会导致相同的错误。

请帮帮我! 谢谢, Evank28

推荐答案

好的,我想出来了。PyInstaller尚未为Python3.6做好准备,这是在将PyInstaller与Python3.6一起使用时发生的错误。我卸载了Pyinstaller,并在命令提示符下使用以下命令安装了Pyinstaller的开发版本。

pip uninstall pyinstaller
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop

然后,像往常一样使用pyinstaller,它就会像魔咒一样工作。官方安装目前还不支持Python3.6版。

pyinstaller myprogram.py

这篇关于Pyinstaller和py2exe导致错误:&quot;元组索引超出范围&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆