[Software/Python question] OpenGL for ubuntu 22.10

Hello, this might be more an OS issue than a laptop one, but i hope someone here had similar issues. I have an python programm that uses the gym-retro and it requires openGL. Getting Started — Gym Retro documentation

i get this error message in visual studio code:

ImportError:
Error occured while running ‘from pyglet.gl import *’
HINT: make sure you have OpenGL installed. On Ubuntu, you can run ‘apt-get install python-opengl’.
If you’re running on a server, you may need a virtual frame buffer; something like this should work: ‘xvfb-run -s “-screen 0 14000x900x24” Pythong <your_script.py>’

the command “apt-get install python-opengl” does not work, i did some tutorials on installing it like this one: OpenGL Setup: Guide to Install OpenGL in Ubuntu | Geek Culture
i got to the point where it says: “cmake .” which does not work. i get the error message:

Cmake Error: Unable to (re)create the private pkgRedirects directory: /usr/local/lib/glfw/CMakeFiles/pkgRedirects

never the less, when i do this command "glxinfo | grep “OpenGL version”
i get this:

OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.2.1

so i have it. but visual studio code does not use it. Did someone have an idea how to fix it?
it is not an issue with the code, it works under windows.
Thanks in advance

hi. i think these questions are better answered on stackoverflow as they have little to do with the laptop :slight_smile:

regardless. did you follow these instructions? in theory if you install pyglet via pip it installs the dependencies (it does on my machine & distribution).

@marco yeah i will post there too. i already did on reddit and on ubuntu discord, but still no responses. i hoped that someone here with the same machine would have a solution rather than people with different hardware. idk if that matters. i am very new to ubuntu.

your suggest, i checked and i already have pyglet(1.5.27) so i guess that wasnt the issue.

have you installed it with pip? i just created a virtualenv and installed it inside the virtualenv and i don’t have your issue.

yes, i have made an enviroment with conda to install python 3.7.13 and use pip for the rest

so i have a hint from someone else, that openGL might not be the issue, the ide may thing it is. so here is the full error message which i ignored for some reason:

Traceback (most recent call last):
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/gym/envs/classic_control/rendering.py”, line 27, in
from pyglet.gl import *
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/pyglet/gl/init.py”, line 95, in
from pyglet.gl.lib import GLException
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/pyglet/gl/lib.py”, line 149, in
from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/pyglet/gl/lib_glx.py”, line 46, in
glu_lib = pyglet.lib.load_library(‘GLU’)
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/pyglet/lib.py”, line 164, in load_library
raise ImportError(‘Library “%s” not found.’ % names[0])
ImportError: Library “GLU” not found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “main.py”, line 291, in
main(args)
File “main.py”, line 60, in main
testPopulation.elitismSelection(1)[0], world, level)
File “main.py”, line 197, in testingIndividual
env.render()
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/retro/retro_env.py”, line 228, in render
from gym.envs.classic_control.rendering import SimpleImageViewer
File “/home/sam/anaconda3/envs/mairio/lib/python3.7/site-packages/gym/envs/classic_control/rendering.py”, line 35, in
“”"
ImportError:
Error occurred while running from pyglet.gl import *
HINT: make sure you have OpenGL installed. On Ubuntu, you can run ‘apt-get install python-opengl’.
If you’re running on a server, you may need a virtual frame buffer; something like this should work:
‘xvfb-run -s “-screen 0 1400x900x24” python <your_script.py>’

so for some reason VSC does not find the GLU libary which should be in gym. the pip list of the ubuntu enviroment and the windows enviroment are the same. so it should be identical. and i dont know why it doesnt find it on ubuntu.

Have you seen this StackOverflow question? :slight_smile: python 3.x - ImportError: Library "GLU" not found - Stack Overflow

tl;dr: sudo apt install freeglut3-dev might help.

@Petr_Sedlacek yes, already installed… sadly not the case. so the problem might be with vscode or the gym package. which is weird, because i use the same versions on my windows machine and there it is fine.