导入时PyInstaller问题

时间:2017-06-03 00:55:43

标签: python pyinstaller

我遇到PyInstaller这个问题。当我将程序拖入以将其转换为.exe时,会发生这种情况(我在Windows上):

    C:\Users\alpac\AppData\Local\Programs\Python\Python36-32\Scripts>pyinstaller.exe --onefile C:\Users\alpac\PycharmProjects\ProgramTests\ProgramTests.py
1748 INFO: PyInstaller: 3.2.1
1748 INFO: Python: 3.6.1
1749 INFO: Platform: Windows-10-10.0.14393-SP0
1754 INFO: wrote C:\Users\alpac\AppData\Local\Programs\Python\Python36-32\Scripts\ProgramTests.spec
1756 INFO: UPX is not available.
1757 INFO: Extending PYTHONPATH with paths
['C:\\Users\\alpac\\PycharmProjects\\ProgramTests',
 'C:\\Users\\alpac\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts']
1758 INFO: checking Analysis
1758 INFO: Building Analysis because out00-Analysis.toc is non existent
1759 INFO: Initializing module dependency graph...
1762 INFO: Initializing module graph hooks...
1773 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "C:\Users\alpac\AppData\Local\Programs\Python\Python36-32\Scripts\pyinstaller-script.py", line 11, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\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:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
    self.__postinit__()
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
    self.assemble()
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
    graph.import_hook(m)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
    source_package, target_module_partname, level)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
    module_basename, module_name, parent_package)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module
    self._scan_code(m, co, co_ast)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
    module, module_code_object, is_scanning_imports=False)
  File "c:\users\alpac\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode
    global_attr_name = get_operation_arg_name()
  File "c:\users\alpac\appdata\local\programs\python\python36-32\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

上半场似乎很正常,但后来有点奇怪。我有最新版本的PyInstaller和Python。

1 个答案:

答案 0 :(得分:0)

目前发布了这个问题,PyInstaller并不支持Python 3.6,正如我们在changelog

中看到的那样

现在通常它在这种配置下应该可以正常工作。