Mujoco-py: Install mujoco with error "/usr/bin/ld: cannot find -lGL"

Created on 17 Jan 2019  路  3Comments  路  Source: openai/mujoco-py

Describe the bug
Install MuJoCo via pip3 install -U 'mujoco-py<1.50.2,>=1.50.1', I got

    /usr/bin/ld: cannot find -lGL
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I could open the simulation by running ../mjpro150/bin: $ ./simulate ../model/humanoid.xml, but the prompt window closes in a very short time.

To Reproduce
The mjkey.txt is placed in /home/libowu/.mujoco/. Add the environment variable with $LD_LIBRARY_PATH=/home/libowu/.mujoco/mjpro150/bin.
Then run pip3 install -U 'mujoco-py<1.50.2,>=1.50.1.

Error Messages
```
Failed building wheel for mujoco-py
Running setup.py clean for mujoco-py
Failed to build mujoco-py
Installing collected packages: Cython, pycparser, cffi, glfw, pillow, numpy, imageio, lockfile, mujoco-py
Running setup.py install for mujoco-py ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-56irx2oc/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7gn7tzgq-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
Removing old mujoco_py cext /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/cymj_1.50.1.68_36_linuxcpuextensionbuilder_36.so
running build_ext
building 'mujoco_py.cymj' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py -I/home/libowu/.mujoco/mjpro150/include -I/home/libowu/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/cymj.c -o /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.68_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/cymj.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py -I/home/libowu/.mujoco/mjpro150/include -I/home/libowu/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/gl/osmesashim.c -o /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.68_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.68_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/cymj.o /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.68_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/gl/osmesashim.o -L/home/libowu/.mujoco/mjpro150/bin -Wl,--enable-new-dtags,-R/home/libowu/.mujoco/mjpro150/bin -lmujoco150 -lglewosmesa -lOSMesa -lGL -o /tmp/pip-build-56irx2oc/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.68_36_linuxcpuextensionbuilder/lib.linux-x86_64-3.6/mujoco_py/cymj.cpython-36m-x86_64-linux-gnu.so -fopenmp
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-56irx2oc/mujoco-py/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7gn7tzgq-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-56irx2oc/mujoco-py/

```
Desktop (please complete the following information):

  • OS: Ubuntu 18.04
  • Python Version [3.7.1]
  • Mujoco Version [1.50]

Environment

  • output of: echo $LD_LIBRARY_PATH
    /home/libowu/.mujoco/mjpro150/bin
  • output of: echo $HOME: /home/libowu
  • output of: echo $USER:libowu

Most helpful comment

Thank you so much @colllin, the issue is fixed by sudo apt install libgl1-mesa-dev.

All 3 comments

I am experiencing the same issue

I was experiencing a similar issue just now. This fixed it: https://stackoverflow.com/a/54397235/361609

Thank you so much @colllin, the issue is fixed by sudo apt install libgl1-mesa-dev.

Was this page helpful?
0 / 5 - 0 ratings