Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command 'gcc' failed with exit status 1 #284

Open
inspirepassion opened this issue Sep 1, 2018 · 24 comments
Open

command 'gcc' failed with exit status 1 #284

inspirepassion opened this issue Sep 1, 2018 · 24 comments

Comments

@inspirepassion
Copy link

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

@BrunoBSM
Copy link

BrunoBSM commented Sep 1, 2018

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

@inspirepassion
Copy link
Author

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

@BrunoBSM
Copy link

BrunoBSM commented Sep 1, 2018

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

@inspirepassion
Copy link
Author

inspirepassion commented Sep 1, 2018

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.

@Jerryxiaoyu
Copy link

Jerryxiaoyu commented Sep 2, 2018

same error...

@karamarieliu
Copy link

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

@LJ147
Copy link

LJ147 commented Jan 4, 2019

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

@jonas-eschle
Copy link

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

@YuYangguang
Copy link

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

@cying9
Copy link

cying9 commented Apr 7, 2019

@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

@s-hong-s
Copy link

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)

@levifussell
Copy link

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

@MonaHe123
Copy link

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

@XueminLiu111
Copy link

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

@typoverflow
Copy link

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

@mbilalai
Copy link

mbilalai commented Sep 8, 2021

@levifussell You're a lifesaver man!

@ritwizsinha
Copy link

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

@DailinH
Copy link

DailinH commented Dec 21, 2021

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

@atonkamanda
Copy link

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 !

@molumitu
Copy link

@atonkamanda It also works for me (Ubuntu 20.04)

@Alipira
Copy link

Alipira commented May 13, 2022

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

@jingxuxie
Copy link

This works for me on Ubuntu 22.04. Thank you!

@BUAAZhangHaonan
Copy link

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

@TianyuCodings
Copy link

libglfw-dev
libglew-dev
libosmesa6-dev
gcc

Install them by sudo, then it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests