Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples are a glitchy mess #2

Gadgetoid opened this issue Jul 28, 2021 · 1 comment

Examples are a glitchy mess #2

Gadgetoid opened this issue Jul 28, 2021 · 1 comment


Copy link

@Gadgetoid Gadgetoid commented Jul 28, 2021

In some instances the examples may look like this:


This is due to somewhat old pygame/SDL versions being shipped with Raspberry Pi OS.

Raspberry Pi 3 etc

On Pi 3B+, Pi Zero and other pre-Pi4 boards you can update pygame from pip to fix glitchiness:

sudo python3 -m pip install pygame --upgrade

Raspberry Pi 4

On Pi 4, you should upgrade pygame as above but it will probably result in this error when you try and run an example:

* failed to add service - already in use?

I believe this, followed by the unhelpful hard exit(1) is caused by this code:

In any case the only way to work around this seems to be by compiling SDL from source... 😬 ... and using your shiny new SDL to replace the system one used by pygame.

You can do that with the following steps:

cd SDL2-2.0.14
./configure --enable-video-rpi --enable-video-kmsdrm --prefix=`pwd`/install
make install

This will install SDL into an "install" directory within the "SDL2-2.0.14" directory, so don't delete it. (You can change the --prefix when configuring to something like /opt/SDL2-2.0.14 if you're so inclined, it doesn't really matter where you put it.)

Once built the new SDL libraries will be available in install/lib, find the full path by typing:

cd install/lib

In my case the path is /home/pi/SDL2-2.0.14/install/lib.

Now when running an example from this repository, you should prefix the command line with LD_LIBRARY_PATH=/home/pi/SDL2-2.0.14/install/lib, for example:

sudo LD_LIBRARY_PATH=/home/pi/SDL2-2.0.14/install/lib python3

If everything is set up correctly on your Pi 4 you should see "Using driver: kmsdrm"

Copy link

@sorryaboutyourcats sorryaboutyourcats commented Aug 4, 2021

Thank you for this info - updating pygame fixed the issue on the Pi Zero. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants