2

I was trying py2exe on a simple script; if I'm correct, the command I have to use in the console to start building the .exe file is

build_exe myscript.py

but when I do this I get this error:

Traceback (most recent call last):
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Python37-32\Scripts\build_exe.exe\__main__.py", line 9, in <module>
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\build_exe.py", line 141, in main
    builder.analyze()
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\runtime.py", line 160, in analyze
    self.mf.import_hook(modname)
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
    self._scan_code(module.__code__, module)
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "c:\program files (x86)\python37-32\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range

What am I doing wrong? Thanks!

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Franz
  • 53
  • 1
  • 1
  • 5
  • Try to avoid using the word "this" in titles where someone would have to click through to know what it refers to -- enough information to specifically identify the question should be in the title itself. – Charles Duffy Apr 08 '19 at 01:53
  • Beyond that, it would be helpful to have a *complete* [mcve] -- code you've tested to contain 100% of the code and configuration needed to reproduce the problem (but nothing not necessary towards that end) – Charles Duffy Apr 08 '19 at 01:56

2 Answers2

0

The last Python version supported by Py2exe was Python 3.4 and maybe 3.5. In Python 3.6 there were changes in CPython that made current py2exe useless. Py2exe has not had any update in many years, so it can be considered abandonware.

You have a more detailed discussion in this SO post.

joaquin
  • 82,968
  • 29
  • 138
  • 152
-1

Create a file named setup.py with the following and place it in the same folder as myscript.py.

from distutils.core import setup
import py2exe
import sip
setup(options={'py2exe':{'bundle_files': 1, 'compressed': True}}, 
    windows=['myscript.py'], zipfile = None)

From a Command Prompt run:

setup.py py2exe
Jeff
  • 57
  • 1
  • 2
  • 7