I’m writing a simple game with python, pygame and py2app. (I use python 2.6) When I build my game in alias mode, it works fine, but when I build for deployment, the app I get crashes immediately after lunching. Anyone know what’s going on?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
To provide a more thorough answer to this whole issue, I’m going to use the aliens.py example.
When built in OS X, you will see quick flash as the game quickly initializes and quits. Opening console reveals an error message similar to
Fatal Python error: (pygame parachute) Segmentation Fault Job appears to have crashed: Abort trap
I believe the issue is that the default font is not being included during the packaging process.
In the aliens.py sample for instance, throw a supported font into your data folder and change
self.font = pygame.font.Font( None ), 20)
to
self.font = pygame.font.Font( os.path.join('data', 'Copperplate.ttc'), 20)
This should allow the app to complie and play without issue.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0