Ant
Ant

Reputation: 5424

Pygame and cx_freeze: segmentation fault

I'm using ubuntu and python 2.6

I found cx freeze already installed on my system (is it there a way to check if it's compatible with my Python version? )

however, i have a small pygame script (which import another module and some images) and i want to compile it;

i used this file as setup.py:

#!/usr/bin/python

from cx_Freeze import setup, Executable

setup(
    name = 'Example',
    version = '0.1',
    description='hi',
    executables = [Executable('/home/antonio/Python 26 save/opt/example.py')]
    )

if i run the resulting executable, (through the terminal) i get this error:

Fatal Python error: (pygame parachute) Segmentation Fault
Aborted

what should i do? I've searched but I found very few examples and I didn't see this error on google results

ps of course the program was running perfectly before using cx freeze

Upvotes: 2

Views: 2280

Answers (5)

DabbingKid
DabbingKid

Reputation: 1

Use pygame.font.SysFont(FONT_NAME, FONT_SIZE).

Upvotes: 0

Rajat Bhatt
Rajat Bhatt

Reputation: 1545

I have been getting the similar error and I think I have found the solution. I am using

pygame.font.SysFont(None,25)

But instead of passing None argument you should use your system's fonts. I have using windows machine so I have replaced none with any font that my system has. So I have replaced it to:

pygame.font.SysFont("comicsansms",25)

As you can see I have replaced None with comicsansms which is preinstalled fonts on windows PC Hope it works!

Upvotes: 0

szmoore
szmoore

Reputation: 944

I have been getting a similar problem using python 2.7. I've found two causes of this segmentation fault in my own program, but I only have a solution to one of them.

Cause 1. Initialising fonts with no path, ie calling:

pygame.font.Font(None, font_size)

In this case, valgrind reports an invalid read at the address 0x0 in ??? in pygame.font.so

I would guess that this is because None is converted to a NULL pointer which something then assumes is a valid const char* string.

The fix for this problem is to always supply a valid path to a font.

Cause 2. Rendering unicode characters in fonts

pygame.font.Font("data/DejaVuSans.ttf", 14).render(u'\u2654')

valgrind reports an invalid read in PyString_AsString in libpython2.7.so.1.0

I'm sorry to say I don't have a solution for this.

PS: I have just found another unicode related (but not pygame related) cause of problems with cxfreeze.

print u'\u2654'

In the python interpreter will print a king (chess piece), but when the script is compiled with cxfreeze, I get the following error (not a segmentation fault):

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2654' in position 0: ordinal not in range(128)

You also get this error in the python interpreter if you call:

print str(u'\u2654')

This seems to indicate that cxfreeze is assuming strings are always ascii strings.

Upvotes: 1

gurney alex
gurney alex

Reputation: 13645

Did you google for your error (http://www.google.com/search?&q=Fatal%20Python%20error%3A%20%28pygame%20parachute%29%20Segmentation%20Fault) and check the various posts reporting the same error ?

E.g.

Upvotes: 0

Samuel Breese
Samuel Breese

Reputation: 714

Do you have any optimization options set when freezing the script? I'm not too sure if it does this, but it may be that it's incorrectly changing a variable to a reference. Again, I'm not an expert at cx_freeze, but my solution would be to update. Do you have the latest version (of cx_freeze)?

Upvotes: 0

Related Questions