Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Python compiling to .exe


ghost's Avatar
0 0

Is it possible to compile a program written in Python to a single file? I have tryed pyInstall which I saw some one claimed that was able to do the trick, but sadley it wern't compatible with 2.6.

So basically, I'am wondring if it is possible with any tools available at the time.


ghost's Avatar
0 0

For what I know py2exe creates several files and cannot compile it all to a single file.


ghost's Avatar
0 0

What about using a file wrapper to make one file out of several?


ghost's Avatar
0 0

Bah I'am a idoit for not reading all the py2exe docs. I found out py2exe was able to do it. It creates one EXE, which temporarily unpacks the components that have be in separate files for Windows to find them. When you terminate the program, the files are removed. You will need to edit the setup.py slightly.

import py2exe, sys, os

sys.argv.append('py2exe')

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

http://stackoverflow.com/questions/112698/py2exe-generate-single-executable-file