5
\$\begingroup\$

I'm using cx_Freeze to package my PyGame game. I'm running Ubuntu Linux, so I used the source package. However, I got the following error when I run cxfreeze game.py:

Fatal Python error: (pygame parachute) Segmentation Fault
Aborted

How can I fix this? I have seen other similar questions but no good answers.

\$\endgroup\$
  • \$\begingroup\$ A segmentation fault is a fairly severe memory-allocation-based error, which Python generally abstracts from the user. It is very uncommon for one to get this kind of error. cxfreeze is definitely doing something odd. Without seeing its source code, however, we can't know what. \$\endgroup\$ – Southpaw Hare Jan 17 '13 at 0:50
1
\$\begingroup\$

You can fix this by finding out what exactly causes the "pygame parachute".

Your first step to find this out is to add detailed logging to your code. Start off with poor man's print() logging:

print("importing pygame")
import pygame
print("initialising pygame")
pygame.init()
...

With that sort of code you might get an error message like

initialising pygame
Fatal Python error: (pygame parachute) Segmentation Fault
Aborted

which helps you to isolate where the problem happened.

Second, cx_freeze is rather tricky. cxfreeze game.py might not be enough to get a working executable. It is a far better practice to set up a setup.py file. See the source code of the Fabula setup file as an example:

http://code.ohloh.net/file?fid=pqI6bOZhHyHchm4NLxcwxsSxVdA&cid=S_RYKZr4PdY

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

I don't know about cxfreeze but your problem might not be specific to it. In my case running under gdb provided a hint:

root@beczulka:/# gdb python3
[...]
(gdb) r -c 'import pygame;pygame.init()'
Starting program: /usr/bin/python3 -c 'import pygame;pygame.init()'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
pygame 1.9.4.post1
Hello from the pygame community. https://www.pygame.org/contribute.html
[New Thread 0x7fffef819700 (LWP 32726)]
No protocol specified
No protocol specified
No protocol specified

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007ffff70427b4 in caca_free_display () from /usr/lib/x86_64-linux-gnu/libcaca.so.0
(gdb) bt
#0  0x00007ffff70427b4 in caca_free_display () from /usr/lib/x86_64-linux-gnu/libcaca.so.0
#1  0x00007ffff7043460 in __caca0_end () from /usr/lib/x86_64-linux-gnu/libcaca.so.0
#2  0x00007ffff7803c0c in ?? () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#3  0x00007ffff77e173e in SDL_VideoQuit () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#4  0x00007ffff77e1b03 in SDL_VideoInit () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#5  0x00007ffff77bad84 in SDL_InitSubSystem () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
#6  0x00007ffff784d41a in ?? () from /usr/lib/python3/dist-packages/pygame/base.cpython-37m-x86_64-linux-gnu.so
#7  0x00007ffff784d4b0 in ?? () from /usr/lib/python3/dist-packages/pygame/base.cpython-37m-x86_64-linux-gnu.so
#8  0x00000000005d6e51 in _PyMethodDef_RawFastCallKeywords ()
#9  0x000000000054b620 in ?? ()
#10 0x0000000000552a01 in _PyEval_EvalFrameDefault ()
#11 0x000000000054bfa2 in _PyEval_EvalCodeWithName ()
#12 0x000000000052e2ff in PyRun_StringFlags ()
#13 0x000000000062fc5d in PyRun_SimpleStringFlags ()
#14 0x0000000000652a08 in ?? ()
#15 0x0000000000652b3e in _Py_UnixMain ()
#16 0x00007ffff7a2009b in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#17 0x00000000005e026a in _start ()
(gdb) 

The name caca_free_display made me realize I was trying to run without a display. Running in an X session, with a DISPLAY set made it work.

| improve this answer | |
\$\endgroup\$
-2
\$\begingroup\$

import pygame I just did this and it works.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ General Notice: if you're going to continue to downvote this answer, please provide a reason. Since the asker failed to provide code samples, this answer is about all that we can assume. Downvoting without explanation also prevents new users from understanding how they can improve in the future. Welcome to GameDev, Naidu! \$\endgroup\$ – Stephan Jan 15 '18 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.