1

I'm using PyCharm 2016.3.2 + Python 3.6 I installed py2exe to compile my simplest script (using pip install py2exe) Installation has been completed successful.

So, I created my following script.py

import os
import winreg

print("Hallo World")

In addition, I created following setup.py as it required by the documentation from official website: setup.py

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')
setup(
    options={
        'py2exe': {
            'compressed': 1,
            'optimize': 2,
            'bundle_files': 3,  # Options 1 & 2 do not work on a 64bit system
            'dist_dir': 'dist',  # Put .exe in dist/
            'xref': False,
            'skip_archive': False,
            'ascii': False,
        }
    },
    zipfile=None,
    console=['script.py'],
)

Then I have tried to run compilation process using terminal windows and command in PyCharm: python setup.py py2exe

C:\Users\folder\Script>python setup.py py2exe
running py2exe
Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    console=['Script.py'],
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
    self._run()
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
    builder.analyze()
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\runtime.py", line 158, in analyze
    self.mf.import_package(modname[:-2])
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 92, in import_package
    self.import_hook(name)
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
    self._scan_code(module.__code__, module)
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Users\folder\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range

As result, I get multiple errors. What I am doing wrong? Please help me.

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253
Quanti Monati
  • 769
  • 1
  • 11
  • 35
  • The duplicate applies here. You're using a tool that depends on the byte-code emitted by Python. In python 3.6 many changes were introduced to it; you'll need to wait for tools that depend on it to fix these changes or use an older version of Python. – Dimitris Fasarakis Hilliard Jan 13 '17 at 19:27
  • **@JimFasarakis-Hilliard** Maybe you can recommend python version that's best in this particular case. I'm using PyCharm 2016.3.2 + Python 3.6 I installed (as I think) the latest version of py2exe - py2exe-0.9.2.2. ? – Quanti Monati Jan 13 '17 at 19:35
  • Pretty sure `3.5` should work just fine (and in a short-while support for `3.6` should come). – Dimitris Fasarakis Hilliard Jan 13 '17 at 19:39
  • Dear **@JimFasarakis-Hilliard**. Thank you very much for your suggestion! – Quanti Monati Jan 13 '17 at 19:41

0 Answers0