Member Avatar for CobRalf

Hello everybody!!
I know that the topic "compiling python script" is a very popular topic, and there are informations about it everywhere on the net.

I use windows and want to make a .exe-executable

My problem:
Everything I found...
* is to old
* does not work (exe has an error, script does not have one)
* pygame does not work
* I have no information about how to include my image/text files in my compiled program

I have found the "pygame2exe" script, but I have no idea of how to use it? It produces an error every time i run it...

Is there any other way to distribute my python app? A special, small portable version of the python interpreter e.g.?

Thank you very much for the help...

Greetz,
cobralf

Py2exe will package all of your files together, although you may need to specify resources, it even bundles all of the packages python needs and the interpriter (my programs end up at about 6MB after packaging).

try:
    import py2exe
    import sys
    from distutils.core import setup
    import os
except ImportError, err:
    print("Couldn't load module: %s" % (err))
    exit(2)


#Windows setup
sys.argv.append('py2exe')

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

More info + Tutorial

cobralf,
I was facing the exact same issues, particularly the famous font and mixer DLL errors. I realized that the pygame2exe script available at pygame.org was a few years old, so I gave it a shot and uninstalled python 2.6, and reloaded with the versions listed below. After that, it worked like a charm! You still have to copy all your images, etc. to the dist folder, though. Maybe someday we'll have a more civilized and robust wizard for this, but everyone is too busy tinkering with their game scripts!

python-2.5.4.msi
pygame-1.9.1.win32-py2.5.msi
py2exe-0.6.9.win32-py2.5.exe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.