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

I can't import mujoco_py because of gcc error MacOSX BigSur

Open vittorione94 opened this issue 4 years ago • 8 comments

It seems I can't import mujoco_py

python --version Python 3.6.12 :: Anaconda, Inc.

Package                Version       Location
---------------------- ------------- ------------------------------------------------------------
absl-py                0.11.0
appdirs                1.4.4
appnope                0.1.2
astunparse             1.6.3
attrs                  20.3.0
audioread              2.1.9
backcall               0.2.0
cached-property        1.5.2
cachetools             4.2.1
certifi                2020.12.5
cffi                   1.14.4
chardet                4.0.0
cloudpickle            1.6.0
cycler                 0.10.0
Cython                 0.29.21
decorator              4.4.2
dm-control             0.0.322773188
dm-env                 1.3
dm-tree                0.1.5
docopt                 0.6.2
fasteners              0.16
flake8                 3.8.4
flatbuffers            1.12
future                 0.18.2
gast                   0.3.3
glfw                   2.0.0
google-auth            1.25.0
google-auth-oauthlib   0.4.2
google-pasta           0.2.0
grpcio                 1.32.0
gym                    0.18.0
h5py                   2.10.0
idna                   2.10
imageio                2.9.0
imageio-ffmpeg         0.4.3
importlib-metadata     3.4.0
iniconfig              1.1.1
ipopt                  0.3.0
ipython                7.16.1
ipython-genutils       0.2.0
jedi                   0.18.0
joblib                 1.0.0
Keras                  2.4.3
Keras-Preprocessing    1.1.2
kiwisolver             1.3.1
labmaze                1.0.3
librosa                0.8.0
llvmlite               0.35.0
lockfile               0.12.2
lxml                   4.6.2
Markdown               3.3.3
matplotlib             3.3.3
mccabe                 0.6.1
MeshLabXML             2018.3
moviepy                1.0.3
mujoco-py              2.0.2.13      /Users/vittorio/Documents/mujoco-py
npy-append-array       0.9.6
numba                  0.52.0
numpy                  1.19.5
oauthlib               3.1.0
opt-einsum             3.3.0
packaging              20.8
pandas                 1.1.5
parso                  0.8.1
pexpect                4.8.0
pickleshare            0.7.5
Pillow                 7.2.0
pip                    20.3.3
pluggy                 0.13.1
pooch                  1.3.0
proglog                0.1.9
prompt-toolkit         3.0.8
protobuf               3.14.0
ptyprocess             0.7.0
py                     1.10.0
pyasn1                 0.4.8
pyasn1-modules         0.2.8
pycodestyle            2.6.0
pycparser              2.20
pydmps                 0.2
pyflakes               2.2.0
pyglet                 1.5.0
Pygments               2.7.3
PyOpenGL               3.1.5
pyparsing              2.4.7
pytest                 6.2.1
python-dateutil        2.8.1
pytz                   2020.5
PyYAML                 5.3.1
requests               2.25.1
requests-oauthlib      1.3.0
resampy                0.2.2
rsa                    4.7
scikit-learn           0.24.0
scipy                  1.5.4
seaborn                0.11.1
setuptools             53.0.0
six                    1.15.0
SoundFile              0.10.3.post1
tensorboard            2.4.1
tensorboard-plugin-wit 1.8.0
tensorflow             2.4.1
tensorflow-estimator   2.4.0
tensorflow-probability 0.12.1
termcolor              1.1.0
threadpoolctl          2.1.0
toml                   0.10.2
tqdm                   4.55.1
traitlets              4.3.3
typing-extensions      3.7.4.3
urllib3                1.26.3
wcwidth                0.2.5
Werkzeug               1.0.1
wheel                  0.36.2
wrapt                  1.12.1
xmltodict              0.12.0
zipp                   3.4.0

when executing: python -c "import mujoco_py"

running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-8 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/vittorio/anaconda3/envs/py36/include -arch x86_64 -I/Users/vittorio/anaconda3/envs/py36/include -arch x86_64 -DONMAC -Imujoco-py/mujoco_py -I/Users/vittorio/Documents/mujoco-py/mujoco_py -I/Users/vittorio/.mujoco/mujoco200/include -I/Users/vittorio/anaconda3/envs/py36/lib/python3.6/site-packages/numpy/core/include -I/Users/vittorio/anaconda3/envs/py36/include/python3.6m -c /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c -o /Users/vittorio/Documents/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.13_36_macextensionbuilder/temp.macosx-10.9-x86_64-3.6/Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.o -fopenmp -w
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:69,
                 from /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:78,
                 from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:25,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h: In function 'renameat':
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h:39:56: error: expected declaration specifiers before '__AVAILABILITY_INTERNAL__MAC_10_10'
 int     renameat(int, const char *, int, const char *) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:78,
                 from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:25,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:81:25: error: storage class specified for parameter 'fpos_t'
 typedef __darwin_off_t  fpos_t;
                         ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:139:2: error: expected specifier-qualifier-list before 'fpos_t'
  fpos_t (* _Nullable _seek) (void *, fpos_t, int);
  ^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:157:3: error: storage class specified for parameter 'FILE'
 } FILE;
   ^~~~
In file included from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:25,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:81:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern FILE *__stdinp;
             ^
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:82:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern FILE *__stdoutp;
             ^
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:83:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern FILE *__stderrp;
             ^
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:156:16: error: expected declaration specifiers or '...' before 'FILE'
 void  clearerr(FILE *);
                ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:157:13: error: expected declaration specifiers or '...' before 'FILE'
 int  fclose(FILE *);
             ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:158:11: error: expected declaration specifiers or '...' before 'FILE'
 int  feof(FILE *);
           ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:159:13: error: expected declaration specifiers or '...' before 'FILE'
 int  ferror(FILE *);
             ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:160:13: error: expected declaration specifiers or '...' before 'FILE'
 int  fflush(FILE *);
             ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:161:12: error: expected declaration specifiers or '...' before 'FILE'
 int  fgetc(FILE *);
            ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:162:14: error: expected declaration specifiers or '...' before 'FILE'
 int  fgetpos(FILE * __restrict, fpos_t *);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:162:33: error: expected declaration specifiers or '...' before 'fpos_t'
 int  fgetpos(FILE * __restrict, fpos_t *);
                                 ^~~~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:163:37: error: expected declaration specifiers or '...' before 'FILE'
 char *fgets(char * __restrict, int, FILE *);
                                     ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:165:1: error: expected declaration specifiers before 'FILE'
 FILE *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fopen));
 ^~~~
In file included from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:25,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:169:14: error: expected declaration specifiers or '...' before 'FILE'
 int  fprintf(FILE * __restrict, const char * __restrict, ...) __printflike(2, 3);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:170:17: error: expected declaration specifiers or '...' before 'FILE'
 int  fputc(int, FILE *);
                 ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:171:37: error: expected declaration specifiers or '...' before 'FILE'
 int  fputs(const char * __restrict, FILE * __restrict) __DARWIN_ALIAS(fputs);
                                     ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:172:72: error: expected declaration specifiers or '...' before 'FILE'
 size_t  fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
                                                                        ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:173:1: error: expected declaration specifiers before 'FILE'
 FILE *freopen(const char * __restrict, const char * __restrict,
 ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:175:13: error: expected declaration specifiers or '...' before 'FILE'
 int  fscanf(FILE * __restrict, const char * __restrict, ...) __scanflike(2, 3);
             ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:176:12: error: expected declaration specifiers or '...' before 'FILE'
 int  fseek(FILE *, long, int);
            ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:177:14: error: expected declaration specifiers or '...' before 'FILE'
 int  fsetpos(FILE *, const fpos_t *);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:177:35: error: expected ';', ',' or ')' before '*' token
 int  fsetpos(FILE *, const fpos_t *);
                                   ^
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:178:13: error: expected declaration specifiers or '...' before 'FILE'
 long  ftell(FILE *);
             ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:179:79: error: expected declaration specifiers or '...' before 'FILE'
 size_t  fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
                                                                               ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:180:11: error: expected declaration specifiers or '...' before 'FILE'
 int  getc(FILE *);
           ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:183:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__cold'
 void  perror(const char *) __cold;
                            ^~~~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:185:16: error: expected declaration specifiers or '...' before 'FILE'
 int  putc(int, FILE *);
                ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:190:14: error: expected declaration specifiers or '...' before 'FILE'
 void  rewind(FILE *);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:192:14: error: expected declaration specifiers or '...' before 'FILE'
 void  setbuf(FILE * __restrict, char * __restrict);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:193:14: error: expected declaration specifiers or '...' before 'FILE'
 int  setvbuf(FILE * __restrict, char * __restrict, int, size_t);
              ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:196:1: error: expected declaration specifiers before 'FILE'
 FILE *tmpfile(void);
 ^~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/limits.h:63,
                 from /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/limits.h:194,
                 from /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/syslimits.h:7,
                 from /usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/limits.h:34,
                 from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:11,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:200:1: error: expected declaration specifiers before '__attribute__'
 __deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.")
 ^~~~~~~~~~~~~~~~
In file included from /Users/vittorio/anaconda3/envs/py36/include/python3.6m/Python.h:25,
                 from /Users/vittorio/Documents/mujoco-py/mujoco_py/cymj.c:57:
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:203:18: error: expected declaration specifiers or '...' before 'FILE'
 int  ungetc(int, FILE *);
                  ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:204:15: error: expected declaration specifiers or '...' before 'FILE'
 int  vfprintf(FILE * __restrict, const char * __restrict, __gnuc_va_list) __printflike(2, 0);
               ^~~~
/usr/local/Cellar/gcc@8/8.4.0_2/lib/gcc/8/gcc/x86_64-apple-darwin20/8.4.0/include-fixed/stdio.h:219:10: fatal error: _ctermid.h: No such file or directory
 #include <_ctermid.h>
          ^~~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-8' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 510, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 335, in _build_impl
    so_file_path = super()._build_impl()
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 244, in _build_impl
    dist.run_commands()
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/Users/vittorio/Documents/mujoco-py/mujoco_py/builder.py", line 144, in build_extensions
    build_ext.build_extensions(self)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
    _build_ext.build_ext.build_extensions(self)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/Users/vittorio/anaconda3/envs/py36/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-8' failed with exit status 1

Running on MacOS BigSur 11.1

PS: I also tried everything listed here: issue #463 but without success

I've tried also all sort of gcc versions 6, 7, 8, 9

Any help would be much appreciated!

echo $HOME /Users/vittorio

echo $USER vittorio

echo $LD_LIBRARY_PATH (blank)

vittorione94 avatar Feb 24 '21 16:02 vittorione94

Try this it might work for you as well and a little less hacky: https://github.com/openai/mujoco-py/issues/463#issuecomment-549874271

mfogelson avatar Feb 25 '21 15:02 mfogelson

Unfortunately I already tried that and I get the exact same error. :(

vittorione94 avatar Feb 26 '21 14:02 vittorione94

I have the same problem. Tried all gcc's with the same result.

parze avatar Mar 13 '21 21:03 parze

Finally got it work. Maybe? But at least I am able to run spinningup's test case.

  1. Get the latest sdk, not previous versions in catalina issue. Older versions fail with different reasons. However, I don't know the proper way to do this. xcode-select thing didn't work on my laptop. After doing random changes, here is how my sdk directory looks like.
lrwxr-xr-x   1 root  wheel   14 Aug  6 11:38 MacOSX.sdk -> MacOSX11.3.sdk
drwxr-xr-x   8 root  wheel  256 Aug  6 11:16 MacOSX10.14.sdk
drwxr-xr-x  10 root  wheel  320 Aug  6 11:38 MacOSX10.15.sdk
drwxr-xr-x   7 root  wheel  224 Nov 30  2020 MacOSX11.1.sdk
drwxr-xr-x   7 root  wheel  224 Aug  6 11:37 MacOSX11.3.sdk
lrwxr-xr-x   1 root  wheel   14 Aug  6 11:36 MacOSX11.sdk -> MacOSX11.3.sdk
  1. I used gcc installed by brew install gcc@7.
  2. There will be some privacy issue to deal with.

If you have further questions, I can try to help.

liujiang833 avatar Aug 06 '21 06:08 liujiang833

I get a very similar error when trying to import mujoco_py:

running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-8 -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.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DONMAC -Imujoco-py/mujoco_py -I/Users/onno/MPI/mbrl/mujoco-py/mujoco_py -I/Users/onno/.mujoco/mujoco200/include -I/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/lib/python3.8/site-packages/numpy/core/include -I/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c /Users/onno/MPI/mbrl/mujoco-py/mujoco_py/cymj.c -o /Users/onno/MPI/mbrl/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.13_38_macextensionbuilder/temp.macosx-10.14-x86_64-3.8/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc-8: error: this compiler does not support arm64
gcc-8: error: unrecognized command line option '-iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders'
gcc-8: error: unrecognized command line option '-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers'
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/unixccompiler.py", line 118, in _compile
    self.spawn(compiler_so + cc_args + [src, '-o', obj] +
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/ccompiler.py", line 910, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/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.8/lib/python3.8/distutils/spawn.py", line 157, in _spawn_posix
    raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-8' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 510, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 335, in _build_impl
    so_file_path = super()._build_impl()
  File "/Users/onno/MPI/mbrl/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.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 192, in run
    _build_ext.build_ext.run(self)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/Users/onno/MPI/mbrl/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.8/lib/python3.8/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.8/lib/python3.8/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.8/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
    objects = self.compiler.compile(sources,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/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.8/lib/python3.8/distutils/unixccompiler.py", line 121, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-8' failed with exit status 1

I don't know if it's the same problem as above, but it's also a gcc error.. I am not sure why it says "error: this compiler does not support arm64", as I have an Intel CPU. Maybe I am misinterpreting that error.

onnoeberhard avatar Oct 11 '21 10:10 onnoeberhard

I get a very similar error when trying to import mujoco_py:

running build_ext
building 'mujoco_py.cymj' extension
/usr/local/bin/gcc-8 -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.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DONMAC -Imujoco-py/mujoco_py -I/Users/onno/MPI/mbrl/mujoco-py/mujoco_py -I/Users/onno/.mujoco/mujoco200/include -I/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/lib/python3.8/site-packages/numpy/core/include -I/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c /Users/onno/MPI/mbrl/mujoco-py/mujoco_py/cymj.c -o /Users/onno/MPI/mbrl/mujoco-py/mujoco_py/generated/_pyxbld_2.0.2.13_38_macextensionbuilder/temp.macosx-10.14-x86_64-3.8/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/cymj.o -fopenmp -w
gcc-8: error: this compiler does not support arm64
gcc-8: error: unrecognized command line option '-iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders'
gcc-8: error: unrecognized command line option '-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers'
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/unixccompiler.py", line 118, in _compile
    self.spawn(compiler_so + cc_args + [src, '-o', obj] +
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/ccompiler.py", line 910, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/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.8/lib/python3.8/distutils/spawn.py", line 157, in _spawn_posix
    raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/local/bin/gcc-8' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 510, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/Users/onno/MPI/mbrl/mujoco-py/mujoco_py/builder.py", line 335, in _build_impl
    so_file_path = super()._build_impl()
  File "/Users/onno/MPI/mbrl/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.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/onno/.local/share/virtualenvs/mbrl-E31sOzwR/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 192, in run
    _build_ext.build_ext.run(self)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/Users/onno/MPI/mbrl/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.8/lib/python3.8/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.8/lib/python3.8/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.8/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
    objects = self.compiler.compile(sources,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/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.8/lib/python3.8/distutils/unixccompiler.py", line 121, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/usr/local/bin/gcc-8' failed with exit status 1

I don't know if it's the same problem as above, but it's also a gcc error.. I am not sure why it says "error: this compiler does not support arm64", as I have an Intel CPU. Maybe I am misinterpreting that error.

I have the same problem. Could you fix it ?

Nicolas99-9 avatar Oct 27 '21 09:10 Nicolas99-9

@Nicolas99-9

I have the same problem. Could you fix it ?

Alas, no. I had to go with a Linux VM..

onnoeberhard avatar Oct 27 '21 09:10 onnoeberhard

Finally got it work. Maybe? But at least I am able to run spinningup's test case.

  1. Get the latest sdk, not previous versions in catalina issue. Older versions fail with different reasons. However, I don't know the proper way to do this. xcode-select thing didn't work on my laptop. After doing random changes, here is how my sdk directory looks like.
lrwxr-xr-x   1 root  wheel   14 Aug  6 11:38 MacOSX.sdk -> MacOSX11.3.sdk
drwxr-xr-x   8 root  wheel  256 Aug  6 11:16 MacOSX10.14.sdk
drwxr-xr-x  10 root  wheel  320 Aug  6 11:38 MacOSX10.15.sdk
drwxr-xr-x   7 root  wheel  224 Nov 30  2020 MacOSX11.1.sdk
drwxr-xr-x   7 root  wheel  224 Aug  6 11:37 MacOSX11.3.sdk
lrwxr-xr-x   1 root  wheel   14 Aug  6 11:36 MacOSX11.sdk -> MacOSX11.3.sdk
  1. I used gcc installed by brew install gcc@7.
  2. There will be some privacy issue to deal with.

If you have further questions, I can try to help.

This worked for me on Mac Monterey. I deleted all previous CommandLineTools folders and installed them from scratch with xcode-select --install. Deleted ~/.mujoco210 and did pip uninstall mujoco_py and then installed them again. I used gcc@7 and indeed had to give some privacy permissions in mac setting which says "libmujoco210.dylib was installed from browser". The permission thing was in the middle of running import mujoco_py for the first time. Then I was able to run the test code in README.

ran-weii avatar Jan 15 '23 22:01 ran-weii