We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,289 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to compile a pygame script with images etc?

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

3
Contributors
2
Replies
1 Month
Discussion Span
2 Years Ago
Last Updated
3
Views
CobRalf
Newbie Poster
13 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 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

joehms22
Junior Poster
114 posts since Jan 2010
Reputation Points: 28
Solved Threads: 21
Skill Endorsements: 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

tendragons
Newbie Poster
4 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0572 seconds using 2.67MB