mujoco-py icon indicating copy to clipboard operation
mujoco-py copied to clipboard

command 'gcc' failed with exit status 1

Open inspirepassion opened this issue 6 years ago • 25 comments

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 <GL/osmesa.h> ^~~~~~~~~~~~~ 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 avatar Sep 01 '18 00:09 inspirepassion

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 avatar Sep 01 '18 01:09 BrunoBSM

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

inspirepassion avatar Sep 01 '18 01:09 inspirepassion

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 avatar Sep 01 '18 01:09 BrunoBSM

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 <GL/osmesa.h> ^~~~~~~~~~~~~ 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) zhixun@zhixun-MS-7B48:~$ 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 avatar Sep 01 '18 23:09 inspirepassion

same error...

Jerryxiaoyu avatar Sep 02 '18 03:09 Jerryxiaoyu

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

karamarieliu avatar Sep 11 '18 00:09 karamarieliu

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 avatar Jan 04 '19 09:01 LJ147

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

jonas-eschle avatar Jan 04 '19 11:01 jonas-eschle

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

YuYangguang avatar Jan 23 '19 04:01 YuYangguang

@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 avatar Apr 07 '19 10:04 cying9

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 avatar Oct 15 '19 08:10 s-hong-s

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 avatar Mar 20 '20 13:03 levifussell

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 avatar Apr 17 '20 13:04 MonaHe123

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

XueminLiu111 avatar Jul 31 '20 13:07 XueminLiu111

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

typoverflow avatar Oct 29 '20 10:10 typoverflow

@levifussell You're a lifesaver man!

mbilalai avatar Sep 08 '21 06:09 mbilalai

I had installed mujoco200 instead of mjpro150 and had renamed the former to mjpro150 which was causing so many problems

ritwizsinha avatar Oct 28 '21 09:10 ritwizsinha

Had the same error when installing on ubuntu 20.04. I was able to get over this issue by: sudo apt-get install libglew-dev sudo apt install libopengl0 -y

DailinH avatar Dec 21 '21 23:12 DailinH

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

Installing patchelf fixed it for me (Ubuntu 20.04) thank you very much !

atonkamanda avatar Jan 22 '22 06:01 atonkamanda

@atonkamanda It also works for me (Ubuntu 20.04)

molumitu avatar Mar 27 '22 13:03 molumitu

for the "GCC" error, it is because of the C compiler sudo apt-get install gcc and then sudo apt-get install build-essential . for me it works

Alipira avatar May 13 '22 17:05 Alipira

This works for me on Ubuntu 22.04. Thank you!

jingxuxie avatar Oct 23 '22 05:10 jingxuxie

for the "GCC" error, it is because of the C compiler sudo apt-get install gcc and then sudo apt-get install build-essential . for me it works

Very useful guy!!!It works for me on Ubuntu 23

BUAAZhangHaonan avatar Oct 25 '23 13:10 BUAAZhangHaonan

libglfw-dev libglew-dev libosmesa6-dev gcc

Install them by sudo, then it works for me.

TianyuCodings avatar Mar 09 '24 06:03 TianyuCodings

I ran into the same issue. I am creating a conda env on a remote cluster, so I don't have the freedom of using sudo apt.

I followed the instructions provided (https://github.com/openai/mujoco-py) and was successful with mujoco200, mujoco-py==2.0.2.0. However, when I try for mujoco210, mujoco-py==2.1.2.14, I get following error -

Exception has occurred: CompileError command '…/bin/gcc' failed with exit code 1 distutils.errors.DistutilsExecError: command '…/bin/gcc' failed with exit code 1

(I exported all necessary paths for mujoco210)

akharedeepak avatar Jul 03 '24 19:07 akharedeepak