Mujoco-py: command 'gcc' failed with exit status 1

11

I followed the instruction (https://github.com/openai/mujoco-py/), and everything is good until I import mujoco_py, could anyone help with that? Thank you in advance.

import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -B /home/jason/.conda/envs/gpu/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Imujoco_py -I/home/jason/.mujoco/mujoco-py/mujoco_py -I/home/jason/.mujoco/mjpro150/include -I/home/jason/.conda/envs/gpu/lib/python3.6/site-packages/numpy/core/include -I/home/jason/.conda/envs/gpu/include/python3.6m -c /home/jason/.mujoco/mujoco-py/mujoco_py/cymj.c -o /home/jason/.mujoco/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.56_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/jason/.mujoco/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc -pthread -B /home/jason/.conda/envs/gpu/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Imujoco_py -I/home/jason/.mujoco/mujoco-py/mujoco_py -I/home/jason/.mujoco/mjpro150/include -I/home/jason/.conda/envs/gpu/lib/python3.6/site-packages/numpy/core/include -I/home/jason/.conda/envs/gpu/include/python3.6m -c /home/jason/.mujoco/mujoco-py/mujoco_py/gl/osmesashim.c -o /home/jason/.mujoco/mujoco-py/mujoco_py/generated/_pyxbld_1.50.1.56_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/jason/.mujoco/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
/home/jason/.mujoco/mujoco-py/mujoco_py/gl/osmesashim.c:1:10: fatal error: GL/osmesa.h: No such file or directory
#include
^~~~~
compilation terminated.
Traceback (most recent call last):
File "/home/jason/.conda/envs/gpu/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/home/jason/.conda/envs/gpu/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/home/jason/.conda/envs/gpu/lib/python3.6/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/home/jason/.conda/envs/gpu/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

inspirepassion picture inspirepassion  ·  1 Sep 2018

Most helpful comment

13

please type in the shell as
sudo apt-get install libosmesa6-dev
This works for me. Hope it can help you

YuYangguang picture YuYangguang  ·  23 Jan 2019

All comments

0

Well, for me, when I tried the exact instructions I wasn't able to make it work either. What solved for me was installing the dependencies.txt and dependencies.dev.txt before installing mujoco-py

BrunoBSM picture BrunoBSM  ·  1 Sep 2018
0

@BrunoBSM Could you please tell me how to install that two txt files? I’m a newbie to the system?

inspirepassion picture inspirepassion  ·  1 Sep 2018
0

Sure thing, I had the name wrong before, you can simply run
sudo pip install -r requirements.txt
and then
sudo pip install -r requirements.dev.txt
and make sure you have the python version right, I had some real problems with that also

BrunoBSM picture BrunoBSM  ·  1 Sep 2018
0

Update toward what I wrote hours ago.
I download through git the repo to my local folder, and the two txt files are in the folder. So now I install them, using pip install -r requirementss.txt instead of sudo pip ... because the error says: sudo: pip: command not found

But unfortunately, when I use python console, try import mujoco_py, the error is still there:

fatal error: GL/osmesa.h: No such file or directory
#include
^~~~~
Traceback (most recent call last):
File "", line 1, in
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/__init__.py", line 1, in
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 468, in
cymj = load_cython_ext(mjpro_path)
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 90, in load_cython_ext
cext_so_path = builder.build()
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 202, in build
built_so_file_path = self._build_impl()
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 256, in _build_impl
so_file_path = super()._build_impl()
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 225, in _build_impl
dist.run_commands()
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/zhixun/.local/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/zhixun/Downloads/mujoco-py/mujoco_py/builder.py", line 125, in build_extensions
build_ext.build_extensions(self)
File "/home/zhixun/.local/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
self.build_extension(ext)
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/zhixun/.conda/envs/temp36/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1


@BrunoBSM Thanks for the reply, and apologize to this late reply, as my ubuntu crushed yesterday when I tried different things. I just reinstalled the whole system, and set up all the previous preparation.

Now I tried the command, it reports this error:

(gpu36) [email protected]:~$ pip install -r requirements.txt
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Do you by any change know about his? Thank you in advance
I check the python version to be: Python 3.6.0 :: Continuum Analytics, Inc.

inspirepassion picture inspirepassion  ·  2 Sep 2018
0

same error...

Jerryxiaoyu picture Jerryxiaoyu  ·  2 Sep 2018
0

same error. tried the installation of requirements first, didn't work

karamarieliu picture karamarieliu  ·  11 Sep 2018
12

same error. tried the installation of requirements first, didn't work

try to install mujoco-py from source code? This worked well for me:

  1. Get the license key and downloaded mjpro150 ready
  2. Clone mujoco-py to local
  3. cd mujoco-py and Run pip install -e . to build from source code
LJ147 picture LJ147  ·  4 Jan 2019
0

@LJ147 worked for me! I had the same problem and the installation with Master seems to work...

mayou36 picture mayou36  ·  4 Jan 2019
13

please type in the shell as
sudo apt-get install libosmesa6-dev
This works for me. Hope it can help you

YuYangguang picture YuYangguang  ·  23 Jan 2019
3

@LJ147 It seems to work when installing it with bash. However, when I import mujoco_py pkg in python, it starts compiling and fails with 'gcc' error

cying9 picture cying9  ·  7 Apr 2019
0

In my case, missing the package, GL/glew.h, causes this problem. Thus, I installed the 'libglew-dev' package though sudo apt install libflew-dev. (refer to this)

s-hong-s picture s-hong-s  ·  15 Oct 2019
1

I had a slightly different error which was as above but with "fatal error: limits.h: No such file or directory" which I got to after moving beyond the above error by following @YuYangguang, above. To fix this next error (which occurred when trying to import in python interpreter) I did:

(1) Install mujoco-py from source.
(2) install limits.h via library apt-get install libc-dev as per here
(3) install patchelf as per conda install patchelf

levifussell picture levifussell  ·  20 Mar 2020
0

You can try the way bellow,it works for me:
sudo apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig

MonaHe123 picture MonaHe123  ·  17 Apr 2020
0

I tried everything above but still failed. Can anyone help me?

XueminLiu111 picture XueminLiu111  ·  31 Jul 2020
0

Instructions provided by @YuYangguang and @levifussell worked for me.

typoverflow picture typoverflow  ·  29 Oct 2020