python-3.xdockeropenglmesa

OpenGL will not work on Docker container,Mesa installation is not solving the issue


I installed the mesa utilities with the following command in the docker file:

RUN apt-get install -y libgl1-mesa-dev freeglut3-dev mesa-common-dev

but I am getting the error:

from OpenGL.raw.GL import _errors File "/usr/local/lib/python3.9/site-packages/OpenGL/raw/GL/_errors.py", line 4, in <module> _error_checker = _ErrorChecker( _p, _p.GL.glGetError ) AttributeError: 'NoneType' object has no attribute 'glGetError'

is there something I am missing, maybe a neccessary version? This code is right after the OpenGL import

os.environ['PYOPENGL_PLATFORM'] = "osmesa"
os.environ['MESA_GL_VERSION_OVERRIDE'] = "3.3"
from OpenGL import GL, osmesa

Am I installing mesa or opengl correctly on the docker container? if not how can I install it?


Solution

  • Here is the docker command that solved all my issues. If you want Mesa to work in your docker container you are going to need the following:

    RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y
    
    RUN apt-get install -y libgl1-mesa-dev libosmesa6-dev
    

    not sure if the first line is needed but the second definitely is.