Kirsty Douglas
Kirsty Douglas

Reputation: 33

Can't get Pyinstaller to execute python file

I have written a program in Python 3.6 and I tried to use Pyinstaller to execute it but then i found out Pyinstaller will only work up to Python 3.5 so I downloaded that and tried to execute that file it still wont work! I different errors from it cant find the file to:

100 INFO: PyInstaller: 3.2.1
100 INFO: Python: 3.6.0
100 INFO: Platform: Windows-10-10.0.14393-SP0
100 INFO: wrote C:\Python\pyi-env-name\Scripts\ATM.spec
100 INFO: UPX is not available.
100 INFO: Extending PYTHONPATH with paths
['F:\\', 'C:\\Python\\pyi-env-name\\Scripts']
100 INFO: checking Analysis
100 INFO: Building Analysis because out00-Analysis.toc is non existent
100 INFO: Initializing module dependency graph...
100 INFO: Initializing module graph hooks...
100 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
  File "c:\users\kirsty douglas\appdata\local\programs\python\python36\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\kirsty douglas\appdata\local\programs\python\python36\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python\pyi-env-name\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\python\pyi-env-name\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:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
    self.__postinit__()
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
    self.assemble()
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble
    excludes=self.excludes, user_hook_dirs=self.hookspath)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
    graph.import_hook(m)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
    source_package, target_module_partname, level)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
    module_basename, module_name, parent_package)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module
    self._scan_code(m, co, co_ast)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
    module, module_code_object, is_scanning_imports=False)
  File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode
    global_attr_name = get_operation_arg_name()
  File "c:\python\pyi-env-name\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

I literally don't know what else to try I have tried every tutorial I can find and even my teacher doesn't know whats going on!

EDIT:: I just realised that on the second line it says

100 INFO: Python: 3.6.0

So how can I make it use Python 3.5

Upvotes: 2

Views: 1173

Answers (1)

Bushman
Bushman

Reputation: 173

(This should probably be a comment, but.. rep issues)

The printout you posted mentions that you run this as Python 3.6. To avoid this you might want to make sure your PATH variable contains only the installation you need; 3.5.

This should at least fix you running this as the wrong version of python. It might not solve other issues.

EDIT: Environment Variables in Windows:

  • Open File Explorer, and right click on "This PC" in the left pane.
  • Click on Properties in the Context menu that opens.
  • In the left pane, click on Advanced System Settings.
  • Under the "Advanced" tab at the bottom, click on Environment Variables.
  • Select 'Path' in the top pane, and click Edit.
  • Change the path to python to the location of the version you need.

Upvotes: 1

Related Questions