Python Forum
trying to create a .exe with py2exe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: trying to create a .exe with py2exe (/thread-9313.html)



trying to create a .exe with py2exe - ichigo29 - Apr-01-2018

Hello everyone, i'm having a bit of trouble using py2exe.
Here is the code of my setup.py
from distutils.core import setup
import py2exe
setup(console=['log_analyser.py'])
setup.py and log_analyser are on my python file
here is the code i use in my console:

C:\Users\pierre>cd C:\Users\pierre\AppData\Local\Programs\Python\Python36-32

C:\Users\pierre\AppData\Local\Programs\Python\Python36-32>python setup.py py2exe

and then here is the Traceback given to me :
running py2exe
Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    setup(console=['log_analyser.py'])
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
    self._run()
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
    builder.analyze()
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\runtime.py", line 159, in analyze
    self.mf.import_hook(modname)
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
    module = self._gcd_import(name)
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
    return self._find_and_load(name)
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 320, in _find_and_load
    self._scan_code(module.__code__, module)
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 352, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Users\pierre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\py2exe\mf3.py", line 381, in _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range
I'm using python 3.65 and py2exe 0.9.2.0 that are normaly compatible.


RE: trying to create a .exe with py2exe - snippsat - Apr-01-2018

py2exe is only supported up to Python 3.4,do not work on 3.6.
Pyinstaller is the best option,also cx_Freeze work for 3.6.
Pyinstaller has one file option like py2exe.
Example for a console program:
pyinstaller --onefile --console your.py
I have many post where i help with Pyinstaller,
there can be problem in all of these freeze packages to find all dependencies.
Here a tutorial.
Example build with Pandas(has a lot dependencies) to one file.


RE: trying to create a .exe with py2exe - ichigo29 - Apr-01-2018

Thanks it works very well !! :D
I used pyinstaller