conda-forge / mujoco-feedstock

A conda-smithy repository for mujoco.
BSD 3-Clause "New" or "Revised" License
1 stars 4 forks source link

AttributeError: 'NoneType' object has no attribute 'glGetError' when MUJOCO_GL="osmesa" is used #48

Open traversaro opened 8 months ago

traversaro commented 8 months ago

Solution to issue cannot be found in the documentation.

Issue

(mujoco) traversaro@IITBMP014LW012:~$ MUJOCO_GL="osmesa" python -c "import mujoco"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/mujoco/__init__.py", line 47, in <module>
    from mujoco.gl_context import *
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/mujoco/gl_context.py", line 38, in <module>
    from mujoco.osmesa import GLContext as _GLContext
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/mujoco/osmesa/__init__.py", line 31, in <module>
    from OpenGL import GL
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/OpenGL/GL/__init__.py", line 4, in <module>
    from OpenGL.GL.VERSION.GL_1_1 import *
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/OpenGL/GL/VERSION/GL_1_1.py", line 14, in <module>
    from OpenGL.raw.GL.VERSION.GL_1_1 import *
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/site-packages/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in <module>
    from OpenGL.raw.GL import _errors
  File "/home/traversaro/miniforge3/envs/mujoco/lib/python3.12/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'

The problem is that pyopengl is trying to load the OSMesa library, but that was not installed.

Installed packages

(mujoco) traversaro@IITBMP014LW012:~$ conda list
# packages in environment at /home/traversaro/miniforge3/envs/mujoco:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
absl-py                   2.1.0              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
ca-certificates           2024.2.2             hbcca054_0    conda-forge
etils                     1.8.0              pyhd8ed1ab_0    conda-forge
fsspec                    2024.3.1           pyhca7485f_0    conda-forge
glfw                      3.4                  hd590300_0    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
importlib_resources       6.4.0              pyhd8ed1ab_0    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libabseil                 20240116.1      cxx17_h59595ed_2    conda-forge
libblas                   3.9.0           21_linux64_openblas    conda-forge
libcblas                  3.9.0           21_linux64_openblas    conda-forge
libccd-double             2.1                  h59595ed_3    conda-forge
libexpat                  2.6.2                h59595ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.2.0               h807b86a_5    conda-forge
libgfortran-ng            13.2.0               h69a702a_5    conda-forge
libgfortran5              13.2.0               ha4646dd_5    conda-forge
libgomp                   13.2.0               h807b86a_5    conda-forge
libiconv                  1.17                 hd590300_2    conda-forge
liblapack                 3.9.0           21_linux64_openblas    conda-forge
libmujoco                 3.1.3                hfbbffa6_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libopenblas               0.3.26          pthreads_h413a1c8_0    conda-forge
libsqlite                 3.45.2               h2797004_0    conda-forge
libstdcxx-ng              13.2.0               h7e041cc_5    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libxcb                    1.15                 h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxkbcommon              1.7.0                h662e7e4_0    conda-forge
libxml2                   2.12.6               h232c23b_1    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
lodepng                   20220109             h924138e_0    conda-forge
mujoco                    3.1.3                ha770c72_1    conda-forge
mujoco-python             3.1.3           py312h276ad9d_1    conda-forge
mujoco-samples            3.1.3                h59595ed_1    conda-forge
mujoco-simulate           3.1.3                h59595ed_1    conda-forge
ncurses                   6.4.20240210         h59595ed_0    conda-forge
numpy                     1.26.4          py312heda63a1_0    conda-forge
openssl                   3.2.1                hd590300_1    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pyglfw                    2.7.0           py312h7900ff3_0    conda-forge
pyopengl                  3.1.6              pyhd8ed1ab_1    conda-forge
python                    3.12.2          hab00c5b_0_cpython    conda-forge
python_abi                3.12                    4_cp312    conda-forge
qhull                     2020.2               h4bd325d_2    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                69.2.0             pyhd8ed1ab_0    conda-forge
tinyxml2                  10.0.0               h59595ed_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
typing_extensions         4.10.0             pyha770c72_0    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
wayland                   1.22.0               h8c25dac_1    conda-forge
wheel                     0.43.0             pyhd8ed1ab_0    conda-forge
xkeyboard-config          2.41                 hd590300_0    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libx11               1.8.7                h8ee46fc_0    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxinerama          1.1.5                h27087fc_0    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zipp                      3.17.0             pyhd8ed1ab_0    conda-forge

apt dependencies: https://gist.github.com/traversaro/4457e793826e6ee0214245e276567146 .

Environment info

(mujoco) traversaro@IITBMP014LW012:~$ conda info

     active environment : mujoco
    active env location : /home/traversaro/miniforge3/envs/mujoco
            shell level : 1
       user config file : /home/traversaro/.condarc
 populated config files : /home/traversaro/miniforge3/.condarc
                          /home/traversaro/.condarc
          conda version : 24.1.2
    conda-build version : 24.1.2
         python version : 3.10.14.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=24.1.2=0
                          __cuda=12.3=0
                          __glibc=2.35=0
                          __linux=5.15.146.1=0
                          __unix=0=0
       base environment : /home/traversaro/miniforge3  (writable)
      conda av data dir : /home/traversaro/miniforge3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/traversaro/miniforge3/pkgs
                          /home/traversaro/.conda/pkgs
       envs directories : /home/traversaro/miniforge3/envs
                          /home/traversaro/.conda/envs
               platform : linux-64
             user-agent : conda/24.1.2 requests/2.31.0 CPython/3.10.14 Linux/5.15.146.1-microsoft-standard-WSL2 ubuntu/22.04.4 glibc/2.35 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.7
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
traversaro commented 8 months ago

The problem was solved installing mesalib package. As MUJOCO_GL=osmesa is extensively mentioned and referenced in MuJoCo examples, I think we should just add mesalib as a dependency of libmujoco at least on Linux, and call it a day.

traversaro commented 2 months ago

However, this scares me a little: https://github.com/conda-forge/mesalib-feedstock/issues/59 .