安装mujoco报错:distutils.errors.DistutilsExecError: command ‘gcc‘ failed with exit status 1

简介: 安装mujoco报错:distutils.errors.DistutilsExecError: command ‘gcc‘ failed with exit status 1

 如果你一开始就报错gcc的问题的话,我建议你首先看官方的解决办法:

  整个的报错记录如下:

>>> import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -B /home/hzq/anaconda3/envs/TianChi/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ianaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py -I/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py -I/home/hzq/.mujoco/mujoco200/include -I/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/numpy/core/include -I/home/hzq/anaconda3/envs/TianChi/include/python3.6m -c /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/cymj.c -o /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/generated/_pyxbld_2.0.2.13_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/cymj.o -fopenmp -w
gcc -pthread -B /home/hzq/anaconda3/envs/TianChi/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ianaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py -I/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py -I/home/hzq/.mujoco/mujoco200/include -I/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/numpy/core/include -I/home/hzq/anaconda3/envs/TianChi/include/python3.6m -c /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/gl/osmesashim.c -o /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/generated/_pyxbld_2.0.2.13_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/gl/osmesashim.o -fopenmp -w
gcc -pthread -shared -B /home/hzq/anaconda3/envs/TianChi/compiler_compat -L/home/hzq/anaconda3/envs/TianChi/lib -Wl,-rpath=/home/hzq/anaconda3/envs/TianChi/lib -Wl,--no-as-needed -Wl,--sysroot=/ /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/generated/_pyxbld_2.0.2.13_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/cymj.o /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/generated/_pyxbld_2.0.2.13_36_linuxcpuextensionbuilder/temp.linux-x86_64-3.6/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/gl/osmesashim.o -L/home/hzq/.mujoco/mujoco200/bin -Wl,-R/home/hzq/.mujoco/mujoco200/bin -lmujoco200 -lglewosmesa -lOSMesa -lGL -o /home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/generated/_pyxbld_2.0.2.13_36_linuxcpuextensionbuilder/lib.linux-x86_64-3.6/mujoco_py/cymj.cpython-36m-x86_64-linux-gnu.so -fopenmp
/home/hzq/anaconda3/envs/TianChi/compiler_compat/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/unixccompiler.py", line 197, in link
    self.spawn(linker + ld_args)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/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/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 510, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 273, in _build_impl
    so_file_path = super()._build_impl()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 244, in _build_impl
    dist.run_commands()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/mujoco_py-2.0.2.13-py3.6.egg/mujoco_py/builder.py", line 144, in build_extensions
    build_ext.build_extensions(self)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
    _build_ext.build_ext.build_extensions(self)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/command/build_ext.py", line 558, in build_extension
    target_lang=language)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/ccompiler.py", line 717, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "/home/hzq/anaconda3/envs/TianChi/lib/python3.6/distutils/unixccompiler.py", line 199, in link
    raise LinkError(msg)
distutils.errors.LinkError: command 'gcc' failed with exit status 1

  这里我就定位到:

/home/hzq/anaconda3/envs/TianChi/compiler_compat/ld: cannot find -lGL
collect2: error: ld returned 1 exit status

  然后看gcc报错,参考这篇帖子:https://github.com/ContinuumIO/anaconda-issues/issues/11152

rename /home/eva/miniconda3/compiler_compat/ld to ld_old. or just delete it.

  把这个什么ld给重命名了,发现还是没啥用。然后又看issue:https://github.com/openai/mujoco-py/issues/374。发现需要重装

apt install libgl1-mesa-glx --reinstall

  重装一下之后就好了。

后续

  我还有尝试过:

https://github.com/cocodataset/cocoapi/issues/94

相关文章
|
3月前
|
NoSQL 编译器 开发工具
006.gcc编译器
gcc是什么?
45 0
006.gcc编译器
|
4月前
|
存储 NoSQL 算法
从一个crash问题展开,探索gcc编译优化细节
问题分析的过程也正是技术成长之路,本文以一个gcc编译优化引发的crash为切入点,逐步展开对编译器优化细节的探索之路,在分析过程中打开了新世界的大门……
423 1
|
12天前
|
C语言
转载 - gcc/ld 动态连接库和静态连接库使用方法
本文介绍了如何在GCC中实现部分程序静态链接、部分动态链接。使用`-Wl`标志传递链接器参数,`-Bstatic`强制链接静态库,`-Bdynamic`强制链接动态库。
18 0
|
1月前
|
编译器 C语言 C++
列举gcc 常见和有用的编译警告选项
列举gcc 常见和有用的编译警告选项
12 0
|
1月前
|
编译器 C语言
gcc编译警告:warning: suggest parentheses around assignment used as truth value
gcc编译警告:warning: suggest parentheses around assignment used as truth value
22 0
|
1月前
|
编译器 Linux C语言
gcc编译器的使用方法
gcc编译器的使用方法
22 1
|
2月前
|
编译器 C语言
gcc/g++语法
gcc/g++语法
|
4月前
|
C语言
gcc静态编译/usr/bin/ld: cannot find -lc
gcc静态编译/usr/bin/ld: cannot find -lc
|
5月前
|
编译器 程序员 C语言
gcc的编译过程和gcc与g++的区别
gcc的编译过程和gcc与g++的区别
54 0
|
6月前
|
C语言
编译安装gcc
编译安装gcc