[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] pygame and py2exe



I'm an experience Python/wxPython programmer new to pygame.  I apologize.
Based on my web searches, this question has been asked many times before,
but I've been unable to find an actual ANSWER that addresses my problem.

I've written my first pygame application and gotten it working perfectly
from the command line.  Now I want to use py2exe to make a stand-alone
application.

I'm using Python 2.3.5, pygame 1.6.2, and py2exe 0.6.3, all on Windows XP.

My main program is called ScaleWalls.py, and it imports a module called
ScaleGUI.py.  The only pygame-py2exe scripts I could locate were quite
obsolete and had many problems, so I gave up on those and started over.
Here's the py2exe script I wrote to package the program up:


#!/usr/bin/env python 
from distutils.core import setup 
import py2exe, pygame 
import glob, shutil 

setup(windows=["ScaleWalls.py"], 
name='Scale Walls game', 
version='0.0.1', 
description='A little game built for the SCALE project', 
author='David K. Woods', 
author_email='dwoods at wcer dot wisc dot edu', 
url='www.wcer.wisc.edu', 
py_modules=['ScaleGUI'] 
) 

shutil.copyfile('ScaleIcon.bmp', 'dist/ScaleIcon.bmp') 
shutil.copyfile('ScaleFont.ttf', 'dist/ScaleFont.ttf') 


As you can see, I made sure to copy the font and icon bitmap my program uses
to my dist folder, where my executable resides.  That seems to have taken
care of the issue for many people with the problems I'm having, but it makes
no difference for me.  

When I try to run my executable, the screen flickers, trying to create the
window, the window closes, and then I get a Microsoft Visual C++ Runtime
Library message saying "Runtime Error!  ...  This application has requested
the Runtime to terminate in an unusual way.  Please contact the
application's support team for more information."  Very helpful, as I AM the
application's support team.

I added a log file, and it appears that pygame.init() successfully returns
(6, 0), but that the program blows up on the next line:

self.screen = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))

I have exactly the same problem when I try to make an executable from the
aliens.py example that comes with pygame.

I'd be grateful if someone can point me to a solution to this problem.  

David Woods