I’m trying to run the OpenGL cube demo from pygame using:
$ python -m pygame.examples.glcube
My setup:
- OS: Ubuntu 24.04.3
- Python: 3.12.11 (installed via Miniconda)
- pygame: 2.6.1
- GPU:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.181 Driver Version: 570.181 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce GTX 1650 Off | 00000000:01:00.0 Off | N/A |
| N/A 51C P8 3W / 50W | 3MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
But I get this error:
pygame 2.6.1 (SDL 2.28.4, Python 3.12.11)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~/miniconda3/envs/myenv/lib/python3.12/site-packages/pygame/examples/glcube.py", line 591, in <module>
main()
File "~/miniconda3/envs/myenv/lib/python3.12/site-packages/pygame/examples/glcube.py", line 541, in main
pg.display.set_mode(display_size, pg.OPENGL | pg.DOUBLEBUF | pg.RESIZABLE)
pygame.error: Could not get EGL display
What I tried
- Verified pygame is installed correctly (
python -m pygame.examples.aliens
works). - Checked if EGL is pointing to the NVIDIA driver
$ ldconfig -p | grep EGL
libEGL_nvidia.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL_nvidia.so.0
ibEGL_nvidia.so.0 (libc6) => /lib/i386-linux-gnu/libEGL_nvidia.so.0
libEGL_mesa.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL_mesa.so.0
libEGL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so.1
libEGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libEGL.so
- Installed
mesa-utils
and confirmed OpenGL works withglxinfo
andglxgears
. - Tried setting
SDL_VIDEODRIVER=x11
but still got the same error.
Question
What does pygame.error: Could not get EGL display
mean in this context, and how can I fix it so I can run the glcube
OpenGL demo?
Is this a problem with my SDL/pygame installation, my GPU drivers, or the way I’m invoking the example?
Any help or workaround would be appreciated. Thank you in advance.
pygame-ce
as well, but I’m still getting the sameCould not get EGL display
error. It seems like EGL is not communicating properly inside my conda environment. For context, I originally ran into this issue while trying to usegenesis-world
visualization, and I tested with the pygame OpenGL example to confirm.