You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pygame.display.init fails if not started by root on Raspberry Pi #3003
Hi! First of all, pygame 1.9.4 is a rather dated version of pygame, perhaps you should upgrade to pygame 2.1.2 (fair warning, pygame2 has issues on pi hardware ATM, so this will likely be slower than pygame 1.9.4)
I'm not really sure, but I believe the videodriver should be set to fbcon in your case. If you used sudo while setting the environment variable, it is invisible to processes run without sudo. So remember to set the environment variable without sudo
Hello @ankith26, thank you for your answer, I tried setting up the SDL_VIDEODRIVER environment variable (directly in the python code with os.environ[...] = ... ) but it doesn't help. Also I don't need to do this to make it work as root, so I think it is a permission issue. Nevertheless I couldn't find which file would it be.
Version 1.9.4 is working fine (is the default when using apt install python3-pygame) and I have the same issue nevertheless with the version 2.1.2 (installed with pip install pygame ).
I cant get pygame to work on a new Pi with attached LCD pi3 or Pi4 it just hangs on init
running python in sudo things work fine.. everything was downloaded and updated for same date as this post
Activity
ankith26 commentedon Jan 30, 2022
Hi! First of all, pygame 1.9.4 is a rather dated version of pygame, perhaps you should upgrade to pygame 2.1.2 (fair warning, pygame2 has issues on pi hardware ATM, so this will likely be slower than pygame 1.9.4)
I'm not really sure, but I believe the videodriver should be set to fbcon in your case. If you used sudo while setting the environment variable, it is invisible to processes run without sudo. So remember to set the environment variable without sudo
Vinalti commentedon Jan 31, 2022
Hello @ankith26, thank you for your answer, I tried setting up the
SDL_VIDEODRIVERenvironment variable (directly in the python code withos.environ[...] = ...) but it doesn't help. Also I don't need to do this to make it work as root, so I think it is a permission issue. Nevertheless I couldn't find which file would it be.Version 1.9.4 is working fine (is the default when using apt install
python3-pygame) and I have the same issue nevertheless with the version 2.1.2 (installed withpip install pygame).robertpfeiffer commentedon Mar 31, 2022
Which version of Raspberry Pi OS are you on? With the latest version of PyGame and Pi OS, I would not recommend fbcon (but that would be correct for PyGame 1.9.4) but KMS/DRM. https://wiki.libsdl.org/FAQUsingSDL
robertpfeiffer commentedon Mar 31, 2022
It feels like there is some vital context missing here
SpudGunMan commentedon Apr 24, 2025
I cant get pygame to work on a new Pi with attached LCD pi3 or Pi4 it just hangs on init
running python in sudo things work fine.. everything was downloaded and updated for same date as this post
SpudGunMan commentedon Apr 24, 2025
figured out a work around!
find your display, likely fb0
ls -l /dev/fb*allow all access
sudo chmod a+rw /dev/fb0