Py2Exe takes your Python code file and packages it into an executable file that you can distribute to a client that does not have Python installed. The executable file contains your byte code, all the required modules and the Python interpreter. It is not a small file.

The snippet is a template to run Py2Exe. For convenience, all the needed modification are done to the last line of the snippet. It is best to have this snippet, modified to accept your code file, and your code file in the same directory. Just follow the instructions in the remark section.

Note that Py2Exe only works with the Windows OS, and is freely available from:
http://www.py2exe.org/

# Py2Exe version 0.6.3 setup file for console programs.
# If this is a windows GUI application replace the last line with
# windows = [{"script": 'myFile.py'}] )
#
# Enter the file name of your own .py code file in the last line, lets say it's test1.py
# so the last line should be: console = [{"script": 'test1.py'}] )
# then save this program as   p2e_test1.py  to the same directory where your code file is located
# Now run p2e_test1.py ...
#
# Two subfolders will be created, called  build and  dist.
# The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe (needed for os.popen() only)
# Your .exe file contains your byte code, all needed modules and the Python interpreter.
# The MSVCR71.dll can be distributed, but is often already in the system32 folder.
# The build folder can be deleted.
# tested with Python24 and Py2Exe v0.6.3 by   vegaseat   27may2006

from distutils.core import setup
import py2exe
import sys

# no arguments
if len(sys.argv) == 1:
    sys.argv.append("py2exe")

# creates a standalone .exe file, no zip files
setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}},
       zipfile = None,
       # replace myFile.py with your own code filename here ...
       console = [{"script": 'myFile.py'}] )

Cool, I think this just what I am looking for for packaging future Python builds for release. The program to do this is this short? Nice. ;)

would there be any way of getting an icon onto this because i know how to do it in the normal py2exe but i still want all the needed modules and things packed inside the exe.?

Wait no... I've now done it... All i did was modify the very end of the script :)

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.