2

Ok so I have a fairly simple python program that utilizes tkinter and win32 to modify an existing excel sheet. I'm attempting to package it as an .exe with pyinstaller. I've read all the information about the 'tuple out of range' error regarding python 3.6. So I downloaded python 2.7, and I've made sure that it's earlier in the path than 3.6. When I enter: python -- version 2.7 output now and not a 3.6... however I STILL get the tuple out of range error when I try to package my .py file. I have the build and dist folder created, both are empty. It's driving me insane and I can't find anything on here about the tuple error that doesn't relate to my python version being incorrect. Any help would be GREATLY appreciated.

The traceback:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Lab>python --version
Python 2.7.13

C:\Users\Lab>C:\Python27\pyinstaller.exe --onefile C:\Python27\TableGen.py
82 INFO: PyInstaller: 3.2.1
82 INFO: Python: 3.6.2
83 INFO: Platform: Windows-7-6.1.7601-SP1
83 INFO: wrote C:\Users\Lab\TableGen.spec
84 INFO: UPX is not available.
85 INFO: Extending PYTHONPATH with paths
['C:\\Python27', 'C:\\Users\\Lab']
85 INFO: checking Analysis
85 INFO: Building Analysis because out00-Analysis.toc is non existent
86 INFO: Initializing module dependency graph...
87 INFO: Initializing module graph hooks...
89 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
    File "c:\users\lab\appdata\local\programs\python\python36-32\lib\runpy.py", li
ne 193, in _run_module_as_main
    "__main__", mod_spec)
    File "c:\users\lab\appdata\local\programs\python\python36-32\lib\runpy.py", li
ne 85, in _run_code
    exec(code, run_globals)

    File "C:\Python27\pyinstaller.exe\__main__.py", line 9, in <module>

    File "c:\users\lab\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\lab\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\lab\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\lab\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\lab\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
    self.__postinit__()

    File "c:\users\lab\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
    self.assemble()

    File "c:\users\lab\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\lab\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\lab\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\lab\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\lab\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\lab\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\lab\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\lab\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\lab\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\lab\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

C:\Users\Lab>

roganjosh
  • 12,594
  • 4
  • 29
  • 46
Ian
  • 33
  • 3
  • What is the actual error you get? Do you have the traceback? Also, what makes you think this had anything at all to do with your version of Python? – roganjosh Aug 11 '17 at 19:10
  • I do have the traceback. The error is IndexError: tuple index out of range. – Ian Aug 11 '17 at 19:15
  • The python version seems to be the most popular fix for that error as far as I can tell. But clearly that's not always the case... – Ian Aug 11 '17 at 19:16
  • Well perhaps you would like to share the traceback? I am aware of the error, we need to see what generates it. – roganjosh Aug 11 '17 at 19:16
  • Ok so now I'm seeing that it's still recognizing python as 3.6.2... but when I enter python --version the ouput is 2.7.13 – Ian Aug 11 '17 at 19:18
  • Ok, seems your Google searches were correct. Indeed it's a known issue, I get in the habit of asking for tracebacks for new users because 99.9% of times the reluctance to provide it stops progress so I don't spend time researching until it's there. [this](https://stackoverflow.com/a/3809404/4799172) is hacky but might be worth a try just to get this job done? It seems the easiest of the approaches. There are other ways listed in that question. – roganjosh Aug 11 '17 at 19:49
  • changing the filename for the .exe didn't do the trick. In fact it made everything completely unreadable because 3.6 was my default version of python. Perhaps I'll need to try another packaging type because I can't get past this issue. – Ian Aug 14 '17 at 20:32

0 Answers0