1,105,399 Community Members

How to compile a pygame script with images etc?

Member Avatar
CobRalf
Newbie Poster
10 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
joehms22
Junior Poster
109 posts since Jan 2010
Reputation Points: 18 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
tendragons
Newbie Poster
4 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: