pyopengl
pyopengl copied to clipboard
Issue with osmesa
I have a working render stack, which renders normally when using X11 platform. However when I set the plataform to osmesa the following error happens:
Traceback (most recent call last):
File "main.py", line 12, in <module>
from src.video_renderer import VideoRenderer
File "/home/mateus/dev/still360/src/video_renderer.py", line 2, in <module>
from OpenGL import GL
File "/home/mateus/local/pyopengl/OpenGL/GL/__init__.py", line 4, in <module>
from OpenGL.GL.VERSION.GL_1_1 import *
File "/home/mateus/local/pyopengl/OpenGL/GL/VERSION/GL_1_1.py", line 14, in <module>
from OpenGL.raw.GL.VERSION.GL_1_1 import *
File "/home/mateus/local/pyopengl/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in <module>
from OpenGL.raw.GL import _errors
File "/home/mateus/local/pyopengl/OpenGL/raw/GL/_errors.py", line 4, in <module>
_error_checker = _ErrorChecker( _p, _p.GL.glGetError )
File "/usr/lib64/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/usr/lib64/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libOSMesa.so.8: undefined symbol: glGetError
The most strange is that it was working before, I am using Arch Linux with mesa-18.0.4-1. Any idea on how to fix that without downgrading?
Hi,
I'm having the same error on Arch Linux. Any updates?
Sorry, I wasn't able to replicate the error on current bzr head. But then I don't have the precise rendering environment you're using. For instance, I can run the tests/osdemo.py
on current bzr head on Ubuntu 18.04. That's osmesa 18.0.5-0ubuntu0~18.04.1
.
Traceback (most recent call last):
File "/home/josh/CAD/pyrender/01_Quickstart/minimal_example_for_offscreen_rendering.py", line 31, in <module>
r = pyrender.OffscreenRenderer(viewport_width=640, viewport_height=480, point_size=1.0)
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/pyrender/offscreen.py", line 32, in __init__
self._create()
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/pyrender/offscreen.py", line 129, in _create
self._platform.init_context()
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/pyrender/platforms.py", line 236, in init_context
from OpenGL.osmesa import (
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/OpenGL/osmesa/__init__.py", line 2, in <module>
from OpenGL.raw.osmesa.mesa import *
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/OpenGL/raw/osmesa/mesa.py", line 42, in <module>
@_p.types(OSMesaContext,GLenum, OSMesaContext)
File "/home/josh/anaconda3/envs/cad/lib/python3.6/site-packages/OpenGL/raw/osmesa/mesa.py", line 10, in _f
function,_p.PLATFORM.OSMesa,
AttributeError: 'GLXPlatform' object has no attribute 'OSMesa'
I got above error when trying to use OffscreenRenderer
@liushuya7 / anybody else with the same issue: I resolved this by placing
import os
os.environ["PYOPENGL_PLATFORM"] = "osmesa"
before all other imports - though I doubt this is related to the original issue.
@liushuya7 what you're seeing there is an attempt to import OSMesa specific functionality from a GLX (non-OSMesa) platform. As @jackd noted, to force the platform to be OSMesa, set an environment variable PYOPENGL_PLATFORM=osmesa
either in your console/shell, or at the top of your main script before you import PyOpenGL.
See also #18 which is the same root issue as the original issue.
OSMesa is known to work on Kubuntu 18.04, the error being seen looks basically like "OSMesa can't find OpenGL" or "OSMesa doesn't yet have an OpenGL context" but without the failing code I can't determine which of those cases is most likely.
Given you were seeing successful running before, I'd assume either that OSMesa became more stringent about returning function pointers without a context (something that does happen as upstream libraries tighten their compliance) or that some library has been upgraded to a point where it doesn't load any more.
have you installed mesa, try this link https://pyrender.readthedocs.io/en/latest/install/index.html
- Do this if you have EGL error
- Install mesalib first to use osmesa render instead of egl:
conda install -c conda-forge mesalib
- Then change the environment variable to osmesa:
import os os.environ["PYOPENGL_PLATFORM"] = "osmesa" os.environ["MUJOCO_GL"] = "osmesa"
- Install mesalib first to use osmesa render instead of egl:
Important note: place that block at the beginning of the file to make it work!
import os
os.environ["PYOPENGL_PLATFORM"] = "osmesa"
os.environ["MUJOCO_GL"] = "osmesa"