安装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月前
|
前端开发 C语言
gcc动态库升级
gcc动态库升级
|
1月前
|
编译器 Linux C语言
gcc的编译过程
GCC(GNU Compiler Collection)的编译过程主要包括四个阶段:预处理、编译、汇编和链接。预处理展开宏定义,编译将代码转换为汇编语言,汇编生成目标文件,链接将目标文件与库文件合并成可执行文件。
64 11
|
3月前
|
编译器 开发工具 C语言
Gcc 链接文件
Gcc 链接文件
36 4
|
3月前
|
编译器 C语言 C++
MinGW安装gcc
MinGW安装gcc
91 0
|
5月前
|
自然语言处理 编译器 Go
GCC:GNU编译器
GCC:GNU编译器
|
5月前
|
Java 编译器 Linux
技术经验解读:【转载】详解GCC的下载和安装(源码安装)
技术经验解读:【转载】详解GCC的下载和安装(源码安装)
165 0
|
6月前
|
编译器 Linux 开发工具
|
6月前
|
NoSQL 编译器 开发工具
006.gcc编译器
gcc是什么?
87 0
006.gcc编译器
|
6月前
|
存储 NoSQL 算法
从一个crash问题展开,探索gcc编译优化细节
问题分析的过程也正是技术成长之路,本文以一个gcc编译优化引发的crash为切入点,逐步展开对编译器优化细节的探索之路,在分析过程中打开了新世界的大门……
|
5月前
|
C语言
关于如何解决mingw64安装后配置完环境变量仍然执行不了gcc命令
关于如何解决mingw64安装后配置完环境变量仍然执行不了gcc命令