Mujoco-py: distutils.errors.CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1

Created on 30 Jun 2017  ยท  18Comments  ยท  Source: openai/mujoco-py

Error:

>>> import mujoco_py
Compiling /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.pyx
running build_ext
building 'mujoco_py.cymj' extension
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py
creating /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py/gl
/usr/local/bin/gcc-7 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/anaconda/envs/python3/include -arch x86_64 -DONMAC -I/Users/abhishek/Packages/mujoco-py/mujoco_py -I/Users/abhishek/.mujoco/mjpro150/include -I/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/numpy/core/include -I/Users/abhishek/.virtualenvs/python3/include/python3.5m -c /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c -o /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.5/Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.o -fopenmp -w
/Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c:476:10: fatal error: mjmodel.h: No such file or directory
 #include "mjmodel.h"
          ^~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-7' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/__init__.py", line 1, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 283, in <module>
    cymj = load_cython_ext(mjpro_path)
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 54, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 200, in build
    so_file_path = super().build()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 131, in build
    dist.run_commands()
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 75, in build_extensions
    build_ext.build_extensions(self)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
    self.build_extension(ext)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/Users/abhishek/.virtualenvs/python3/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1

Version:

$ conda list | grep mujoco
mujoco-py                 1.50.0.7                  <pip>
$ python --version
Python 3.5.3 :: Anaconda 4.4.0 (x86_64)

OS:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.5

Possible similar issues:
https://github.com/openai/mujoco-py/issues/43

Most helpful comment

I was able to solve this problem by clone the repo and doing pip install -e '.[all]' with it.
Using Anaconda and Python 3.6.

All 18 comments

Can you try installation without pip, using the command python setup.py install, after cloning/downloading the repository.
It did work for me, even when the pip one failed.
P.S read my comment here

Installing from repository, makes no difference to the error for me.

Any ideas on resolving this issue?

@abhigenie92 use python3.5.2 then install from this git repo solved it for me. For detailed script you can take a look here:
https://github.com/openai/mujoco-py/issues/47#issuecomment-312551946

Update 2019-09-21:

export LD_LIBRARY_PATH=$HOME/.mujoco/mujoco200/bin:$LD_LIBRARY_PATH
export MUJOCO_PY_MJPRO_PATH=$HOME/.mujoco/mujoco200/
export MUJOCO_PY_MJKEY_PATH=$HOME/.mujoco/mjkey.txt

worked. In addition I had to do

brew uninstall gcc
brew uninstall gcc@8
brew uninstall gcc@9

brew install gcc@6

Only the gcc@6 worked with this installation. OSX version is 10.14.6 (18G87)

Note this is also true on Linux. It seems that mujoco-py likes the path without the platform post-fix, where as DeepMind dm_controlsuite likes it with those post-fixes.

@episodeyang Just a heads up, I'm attempting to install on Ubuntu 16.04 and followed the exact commands that you linked in #47 and am still having pretty much the same issue which @abhigenie92 has!

(gym) duncanwilson@naasic-2:~/summer$ python 
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py -I/home/duncanwilson/.mujoco/mjpro150/include -I/home/duncanwilson/summer/mujoco-py/.eggs/numpy-1.13.1-py3.5-linux-x86_64.egg/numpy/core/include -I/home/duncanwilson/anaconda3/envs/gym/include/python3.5m -c /home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/cymj.c -o /home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/cymj.o -fopenmp -w
/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/cymj.c:471:21: fatal error: mjmodel.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/__init__.py", line 1, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/builder.py", line 296, in <module>
    cymj = load_cython_ext(mjpro_path)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/builder.py", line 56, in load_cython_ext
    cext_so_path = builder.build()
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/builder.py", line 119, in build
    built_so_file_path = self._build_impl()
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/builder.py", line 139, in _build_impl
    dist.run_commands()
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/duncanwilson/summer/mujoco-py/.eggs/Cython-0.25.2-py3.5-linux-x86_64.egg/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/command/build_ext.py", line 338, in run
    self.build_extensions()
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/site-packages/mujoco_py-1.50.1.7-py3.5.egg/mujoco_py/builder.py", line 77, in build_extensions
    build_ext.build_extensions(self)
  File "/home/duncanwilson/summer/mujoco-py/.eggs/Cython-0.25.2-py3.5-linux-x86_64.egg/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
    self.build_extension(ext)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
    depends=ext.depends)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/duncanwilson/anaconda3/envs/gym/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
(gym) duncanwilson@naasic-2:~/summer$ conda list | grep mujoco
mujoco-py                 1.50.1.7                  <pip>
(gym) duncanwilson@naasic-2:~/summer$ python -V
Python 3.5.2 :: Continuum Analytics, Inc.
(gym) duncanwilson@naasic-2:~/summer$  lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

Any help with this would be massive! :)

I actually found the isssue, in ~/.mujoco/mjpro150 there was another mjpro150/ folder with mjuoco in it. So I moved the contents of ~/.mujoco/mjpro150/mjpro150 to ~/.mujoco/mjpro150/ and deleted the empty ~/.mujoco/mjpro150/mjpro150 folder and now everything works!

Hope this helps:sparkles:

I also had a ImportError: Failed to load GLFW3 shared library. error after this which was solved by sudo apt-get install libglfw3

This is most likely a mujoco or user error issue, but thought it might be helpful to share!

@Duncanswilson Thanks for the comment! Yes I saw those mistakes. A more damning mistake in my script is one that I'm trying to use mujoco1.50 with the gym. gym only work with mujoco1.3 as far as I know :joy:

Still suck on it.
I am assuming things now support 3.6. And gym works with mujoco150 now.

~/P/mujoco-py [master]ร— ยป python                                          (ppo_latest) 22:50:39
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-7 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/anaconda/envs/ppo_latest/include -arch x86_64 -I/anaconda/envs/ppo_latest/include -arch x86_64 -DONMAC -Imujoco_py -I/Users/abhishek/Packages/mujoco-py/mujoco_py -I/Users/abhishek/.mujoco/mjpro150/include -I/anaconda/envs/ppo_latest/lib/python3.6/site-packages/numpy/core/include -I/anaconda/envs/ppo_latest/include/python3.6m -c /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c -o /Users/abhishek/Packages/mujoco-py/mujoco_py/generated/_pyxbld_MacExtensionBuilder/temp.macosx-10.7-x86_64-3.6/Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.o -fopenmp -w
In file included from /usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/include-fixed/syslimits.h:7:0,
                 from /usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/include-fixed/limits.h:34,
                 from /anaconda/envs/ppo_latest/include/python3.6m/Python.h:11,
                 from /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c:57:
/usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/include-fixed/limits.h:194:61: error: no include path in which to search for limits.h
 #include_next <limits.h>  /* recurse down to the real one */
                                                             ^
In file included from /Users/abhishek/Packages/mujoco-py/mujoco_py/cymj.c:57:0:
/anaconda/envs/ppo_latest/include/python3.6m/Python.h:25:10: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-7' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/__init__.py", line 1, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 439, in <module>
    cymj = load_cython_ext(mjpro_path)
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 80, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 187, in build
    built_so_file_path = self._build_impl()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 280, in _build_impl
    so_file_path = super()._build_impl()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 207, in _build_impl
    dist.run_commands()
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/abhishek/Packages/mujoco-py/.eggs/Cython-0.27.3-py3.6-macosx-10.7-x86_64.egg/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/Users/abhishek/Packages/mujoco-py/mujoco_py/builder.py", line 106, in build_extensions
    build_ext.build_extensions(self)
  File "/Users/abhishek/Packages/mujoco-py/.eggs/Cython-0.27.3-py3.6-macosx-10.7-x86_64.egg/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
    self.build_extension(ext)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/anaconda/envs/ppo_latest/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1
>>> exit()

The folders seem fine for me. ( So @Duncanswilson's suggestion doesn't work for me.)

~/.mujoco ยป tree                                                                       22:51:15
.
โ”œโ”€โ”€ __MACOSX
โ”‚ย ย  โ””โ”€โ”€ mjpro150
โ”‚ย ย      โ””โ”€โ”€ bin
โ”œโ”€โ”€ mjkey.txt
โ”œโ”€โ”€ mjkey_old.txt
โ””โ”€โ”€ mjpro150
    โ”œโ”€โ”€ bin
    โ”‚ย ย  โ”œโ”€โ”€ MUJOCO_LOG.TXT
    โ”‚ย ย  โ”œโ”€โ”€ basic
    โ”‚ย ย  โ”œโ”€โ”€ compile
    โ”‚ย ย  โ”œโ”€โ”€ derivative
    โ”‚ย ย  โ”œโ”€โ”€ libglfw.3.dylib
    โ”‚ย ย  โ”œโ”€โ”€ libmujoco150.dylib
    โ”‚ย ย  โ”œโ”€โ”€ record
    โ”‚ย ย  โ”œโ”€โ”€ simulate
    โ”‚ย ย  โ””โ”€โ”€ test
    โ”œโ”€โ”€ doc
    โ”‚ย ย  โ”œโ”€โ”€ README.txt
    โ”‚ย ย  โ””โ”€โ”€ REFERENCE.txt
    โ”œโ”€โ”€ include
    โ”‚ย ย  โ”œโ”€โ”€ glfw3.h
    โ”‚ย ย  โ”œโ”€โ”€ mjdata.h
    โ”‚ย ย  โ”œโ”€โ”€ mjmodel.h
    โ”‚ย ย  โ”œโ”€โ”€ mjrender.h
    โ”‚ย ย  โ”œโ”€โ”€ mjvisualize.h
    โ”‚ย ย  โ”œโ”€โ”€ mjxmacro.h
    โ”‚ย ย  โ””โ”€โ”€ mujoco.h
    โ”œโ”€โ”€ model
    โ”‚ย ย  โ”œโ”€โ”€ humanoid.xml
    โ”‚ย ย  โ””โ”€โ”€ humanoid100.xml
    โ””โ”€โ”€ sample
        โ”œโ”€โ”€ basic.cpp
        โ”œโ”€โ”€ compile.cpp
        โ”œโ”€โ”€ derivative.cpp
        โ”œโ”€โ”€ makefile
        โ”œโ”€โ”€ record.cpp
        โ”œโ”€โ”€ simulate.cpp
        โ””โ”€โ”€ test.cpp

9 directories, 29 files

If it is matters, I also get this error:

~/.m/m/bin ยป ./simulate ../model/humanoid.xml                                          23:03:54
MuJoCo Pro library version 1.50
ERROR: Could not open activation key file mjkey.txt

Press Enter to exit ...

@abhigenie92 I upgraded my gcc from 7.1 to 7.2, everything seems working now.
brew upgrade gcc

I was able to solve this problem by clone the repo and doing pip install -e '.[all]' with it.
Using Anaconda and Python 3.6.

I'm trying to get this running with gcc 7.3. Have installed mujoco in the proper directory.

Running: import mujoco_py, I get the same: CompileError: command '/usr/local/bin/gcc-7' failed with exit status 1

For me it's _stdio.h that's causing problems...

In file included from /Users/tpearce/anaconda3/include/python3.6m/Python.h:25:0,
                 from /Users/tpearce/anaconda3/lib/python3.6/site-packages/mujoco_py/cymj.c:51:
/usr/local/Cellar/gcc@7/7.3.0/lib/gcc/7/gcc/x86_64-apple-darwin17.5.0/7.3.0/include-fixed/stdio.h:83:10: fatal error: _stdio.h: No such file or directory
 #include <_stdio.h>
          ^~~~~~~~~~
compilation terminated.

I tried linking to /secure/_stdio.h and xlocale/_stdio.h, since there's no _stdio.h file in usr/include but these just lead to different errors.

I also have gcc 8 installed, not sure if that's interfering?

Anyone else have the same problem?

@TeaPearce Were you able to fix it? I have the same issue.

@abhigenie92 Hi, I met the same error "Could not open activation key file" while the key file is actually where it should be. Have you solved this?

came back to this after a while. think it's now working after following this thread https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave

Closing this issue for now because the build system has changed since.

If any new users encounter something similar, please open a new issue! There's an issue template which helps us in getting the information we need.

Thanks~

cd into mujoco-py then
python3 setup.py install
python

import mujoco_py
Compiling /Users/q/phd/mujoco-py/mujoco_py/cymj.pyx because it depends on /Users/q/mujoco_env/lib/python3.7/site-packages/Cython-3.0a4-py3.7.egg/Cython/Includes/numpy/__init__.pxd.
[1/1] Cythonizing /Users/q/phd/mujoco-py/mujoco_py/cymj.pyx
warning: mujoco_py/generated/wrappers.pxi:4:0: Dotted filenames ('../pxd/mujoco.pxd') are deprecated. Please use the normal Python package directory layout.
running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-9 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers -DONMAC -Imujoco_py -I/Users/q/phd/mujoco-py/mujoco_py -I/Users/q/.mujoco/mujoco200/include -I/Users/q/mujoco_env/lib/python3.7/site-packages/numpy-1.18.4-py3.7-macosx-10.14-x86_64.egg/numpy/core/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m -c /Users/q/phd/mujoco-py/mujoco_py/cymj.c -o /Users/q/phd/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.9_37_macextensionbuilder/temp.macosx-10.14-x86_64-3.7/Users/q/phd/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc-9: error: unrecognized command line option '-iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders'
gcc-9: error: unrecognized command line option '-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers'
Traceback (most recent call last):
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-9' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/Users/q/phd/mujoco-py/mujoco_py/__init__.py", line 3, in
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 510, in
cymj = load_cython_ext(mujoco_path)
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 105, in load_cython_ext
cext_so_path = builder.build()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 221, in build
built_so_file_path = self._build_impl()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 335, in _build_impl
so_file_path = super()._build_impl()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 244, in _build_impl
dist.run_commands()
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/q/mujoco_env/lib/python3.7/site-packages/Cython-3.0a4-py3.7.egg/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 144, in build_extensions
build_ext.build_extensions(self)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension
depends=ext.depends)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-9' failed with exit status 1

I have also tried gcc@6, gcc@7, gcc@8

OS: OSX (Catalina the apple Vista)
python3.7
virtualenv

cd into mujoco-py then
python3 setup.py install
python

import mujoco_py
Compiling /Users/q/phd/mujoco-py/mujoco_py/cymj.pyx because it depends on /Users/q/mujoco_env/lib/python3.7/site-packages/Cython-3.0a4-py3.7.egg/Cython/Includes/numpy/init.pxd.
[1/1] Cythonizing /Users/q/phd/mujoco-py/mujoco_py/cymj.pyx
warning: mujoco_py/generated/wrappers.pxi:4:0: Dotted filenames ('../pxd/mujoco.pxd') are deprecated. Please use the normal Python package directory layout.
running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-9 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers -DONMAC -Imujoco_py -I/Users/q/phd/mujoco-py/mujoco_py -I/Users/q/.mujoco/mujoco200/include -I/Users/q/mujoco_env/lib/python3.7/site-packages/numpy-1.18.4-py3.7-macosx-10.14-x86_64.egg/numpy/core/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m -c /Users/q/phd/mujoco-py/mujoco_py/cymj.c -o /Users/q/phd/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.9_37_macextensionbuilder/temp.macosx-10.14-x86_64-3.7/Users/q/phd/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc-9: error: unrecognized command line option '-iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders'
gcc-9: error: unrecognized command line option '-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers'
Traceback (most recent call last):
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/unixccompiler.py", line 118, in _compile
extra_postargs)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py", line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/spawn.py", line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-9' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/Users/q/phd/mujoco-py/mujoco_py/init.py", line 3, in
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 510, in
cymj = load_cython_ext(mujoco_path)
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 105, in load_cython_ext
cext_so_path = builder.build()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 221, in build
built_so_file_path = self._build_impl()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 335, in _build_impl
so_file_path = super()._build_impl()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 244, in _build_impl
dist.run_commands()
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/q/mujoco_env/lib/python3.7/site-packages/Cython-3.0a4-py3.7.egg/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/Users/q/phd/mujoco-py/mujoco_py/builder.py", line 144, in build_extensions
build_ext.build_extensions(self)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension
depends=ext.depends)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-9' failed with exit status 1

I have also tried gcc@6, gcc@7, gcc@8

OS: OSX (Catalina the apple Vista)
python3.7
virtualenv

I solved this by using

brew install llvm
brew install boost
brew install hdf5

# Add this to your .bashrc/.zshrc:
export PATH="/usr/local/opt/llvm/bin:$PATH"

export CC="/usr/local/opt/llvm/bin/clang"
export CXX="/usr/local/opt/llvm/bin/clang++"
export CXX11="/usr/local/opt/llvm/bin/clang++"
export CXX14="/usr/local/opt/llvm/bin/clang++"
export CXX17="/usr/local/opt/llvm/bin/clang++"
export CXX1X="/usr/local/opt/llvm/bin/clang++"

export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

just like the troubleshooting said in README. clang is what you should use.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shubhomb picture shubhomb  ยท  19Comments

tadashiK picture tadashiK  ยท  18Comments

caprest picture caprest  ยท  17Comments

pat-coady picture pat-coady  ยท  39Comments

amyzhang picture amyzhang  ยท  25Comments