pyinstaller失败并出现IndexError

时间:2017-03-17 12:36:29

标签: python pyinstaller

我正在使用Windows 10 64位系统。

我有一个python脚本,用API查询用户定义的数据。具体而言,用户使用input()方法输入几个搜索词。数据以JSON格式检索,我将在控制台上显示或保存在文本文件中,具体取决于用户选择的选项。

我想将此脚本转换为exe,以便用户无需安装python即可运行此脚本。我使用了pyinstaller,但到目前为止都没有成功。

我的系统上安装了anaconda,并按照文档中的建议使用pip安装pyinstaller

pip install pyinstaller
pyinstaller --onefile my_script.py

这些是我得到的错误

236 INFO: PyInstaller: 3.2.1
236 INFO: Python: 3.6.0
236 INFO: Platform: Windows-10-10.0.14393-SP0
236 INFO: wrote C:\Users\Keshav\Documents\Hicotronics\rochester_scrape\data_get2.spec
298 INFO: UPX is available.
298 INFO: Extending PYTHONPATH with paths ['C:\\Users\\Keshav\\Documents\\Hicotronics\\rochester_scrape',  'C:\\Users\\Keshav\\Documents\\Hicotronics\\rochester_scrape']
298 INFO: checking Analysis
298 INFO: Building Analysis because out00-Analysis.toc is non existent
298 INFO: Initializing module dependency graph...
314 INFO: Initializing module graph hooks...
314 INFO: Analyzing base_library.zip ...
Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
self.__postinit__()
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
self.assemble()
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble
excludes=self.excludes, user_hook_dirs=self.hookspath)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
graph.import_hook(m)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
source_package, target_module_partname, level)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module
self._scan_code(m, co, co_ast)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
module, module_code_object, is_scanning_imports=False)
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode
global_attr_name = get_operation_arg_name()
File "c:\programdata\anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operation_arg_name
return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range

请帮我调试一下,因为我不知道导致失败的原因。

1 个答案:

答案 0 :(得分:1)

PyInstaller for Windows 10并不完全支持Python 3.6。 https://github.com/pyinstaller/pyinstaller/issues/2286