Search code examples
pythonpy2exefreeze

Can't get Py2exe to compile to one exe correctly


Hi so I'm trying to create a single exe file that executes my python code.

If I do a bog standard compile with the following setup:

from distutils.core import setup
import py2exe, sys, os, Tkinter, ttk, collections, itertools

setup(
     windows = [{'script': "sortSimi.py"}],
  )

it works fine. Except for the fact the Dist folder is huge and unweildy. If I then try and use the following setup file so that it compiles into one exe:

from distutils.core import setup
import py2exe, sys, os, Tkinter, ttk, collections, itertools


setup(
     options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
     windows = [{'script': "sortSimi.py"}],
     zipfile = None,
)

It compiles but then when I run the exe it just hangs. I've checked on taskmanager. It runs for about 10 seconds and then just disapears. No GUI or anything appears on screen.

What is going wrong??

edit: If I change the 'windows' line to:

  console = ["sortSimi.py"]

then it will open a cmd window, and then notify me that the program isn't responding. I also tried using the first setup file with the '-b 1' argument to invoke the bundling from the command line instead of the setup file, same problem.


Solution

  • bundle_files = 1 is not working well in a lot of circumstances.

    I use bundle_files = 2 and define zipfile = r'lib\library.zip' and then package the lot with InnoSetup into a one file installer.

    If size is an issue then might you want to define excluded = [] and dll_excludes = [] lists.