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.