相关文章推荐
耍酷的作业本  ·  Connect to your ...·  2 月前    · 
狂野的火车  ·  2021-12-03记录:Javascrip ...·  5 月前    · 
耍酷的柑橘  ·  unity button点击事件-掘金·  1 年前    · 

在Linux下安装软件,还是容易出现各种问题,而且是用命令行操作的,往往会出现长长的报错。这时候就需要非常强大的阅读报错的能力。
总而言之,就是 缺啥装啥

open OL库

出现报错如下:

$ python
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Python 3.8.13 (default, Mar 28 2022, 11:38:47)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -B /home/user/miniconda3/envs/py38/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py -I/home/user/.mujoco/mujoco200/include -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include -I/home/user/miniconda3/envs/py38/include/python3.8 -c /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/cymj.c -o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/cymj.o -fopenmp -w
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
gcc -pthread -B /home/user/miniconda3/envs/py38/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py -I/home/user/.mujoco/mujoco200/include -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include -I/home/user/miniconda3/envs/py38/include/python3.8 -c /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.c -o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.o -fopenmp -w
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.c:1:10: fatal error: GL/osmesa.h: No such file or directory
    1 | #include <GL/osmesa.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/unixccompiler.py", line 117, in _compile
    self.spawn(compiler_so + cc_args + [src, '-o', obj] +
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/ccompiler.py", line 910, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/spawn.py", line 157, in _spawn_posix
    raise DistutilsExecError(
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/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 506, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 273, in _build_impl
    so_file_path = super()._build_impl()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 244, in _build_impl
    dist.run_commands()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 144, in build_extensions
    build_ext.build_extensions(self)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
    _build_ext.build_ext.build_extensions(self)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
    self._build_extensions_serial()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
    objects = self.compiler.compile(sources,
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1

在这里,最重要的一句就是

fatal error: GL/osmesa.h: No such file or directory
    1 | #include <GL/osmesa.h>
      |          ^~~~~~~~~~~~~

大概意思就是:出现了致命的错误:没有GL/osmesa.h这个文件。
说明此时缺了OpenGL,这是一个c语言中图形化的一个库,因此我们需要安装这个库。
执行如下命令即可安装:

$ sudo apt install libosmesa6-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm9
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libosmesa6
The following NEW packages will be installed:
  libosmesa6 libosmesa6-dev
0 upgraded, 2 newly installed, 0 to remove and 37 not upgraded.
Need to get 3,063 kB of archives.
After this operation, 13.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 libosmesa6 amd64 21.2.6-0ubuntu0.1~20.04.2 [3,054 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 libosmesa6-dev amd64 21.2.6-0ubuntu0.1~20.04.2 [8,844 B]
Fetched 3,063 kB in 5s (615 kB/s)
Selecting previously unselected package libosmesa6:amd64.
(Reading database ... 128268 files and directories currently installed.)
Preparing to unpack .../libosmesa6_21.2.6-0ubuntu0.1~20.04.2_amd64.deb ...
Unpacking libosmesa6:amd64 (21.2.6-0ubuntu0.1~20.04.2) ...
Selecting previously unselected package libosmesa6-dev:amd64.
Preparing to unpack .../libosmesa6-dev_21.2.6-0ubuntu0.1~20.04.2_amd64.deb ...
Unpacking libosmesa6-dev:amd64 (21.2.6-0ubuntu0.1~20.04.2) ...
Setting up libosmesa6:amd64 (21.2.6-0ubuntu0.1~20.04.2) ...
Setting up libosmesa6-dev:amd64 (21.2.6-0ubuntu0.1~20.04.2) ...
Processing triggers for libc-bin (2.31-0ubuntu9.7) ...

patchelf

出现报错如下:

$ python
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Python 3.8.13 (default, Mar 28 2022, 11:38:47)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco_py
running build_ext
building 'mujoco_py.cymj' extension
gcc -pthread -B /home/user/miniconda3/envs/py38/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py -I/home/user/.mujoco/mujoco200/include -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include -I/home/user/miniconda3/envs/py38/include/python3.8 -c /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/cymj.c -o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/cymj.o -fopenmp -w
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
gcc -pthread -B /home/user/miniconda3/envs/py38/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py -I/home/user/.mujoco/mujoco200/include -I/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include -I/home/user/miniconda3/envs/py38/include/python3.8 -c /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.c -o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.o -fopenmp -w
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
creating /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/lib.linux-x86_64-3.8
creating /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/lib.linux-x86_64-3.8/mujoco_py
gcc -pthread -shared -B /home/user/miniconda3/envs/py38/compiler_compat -L/home/user/miniconda3/envs/py38/lib -Wl,-rpath=/home/user/miniconda3/envs/py38/lib -Wl,--no-as-needed -Wl,--sysroot=/ /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/cymj.o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/temp.linux-x86_64-3.8/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/gl/osmesashim.o -L/home/user/.mujoco/mujoco200/bin -Wl,-R/home/user/.mujoco/mujoco200/bin -lmujoco200 -lglewosmesa -lOSMesa -lGL -o /home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/generated/_pyxbld_2.0.2.8_38_linuxcpuextensionbuilder/lib.linux-x86_64-3.8/mujoco_py/cymj.cpython-38-x86_64-linux-gnu.so -fopenmp
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/__init__.py", line 3, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 506, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 105, in load_cython_ext
    cext_so_path = builder.build()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 221, in build
    built_so_file_path = self._build_impl()
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 275, in _build_impl
    fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so')
  File "/home/user/miniconda3/envs/py38/lib/python3.8/site-packages/mujoco_py/builder.py", line 149, in fix_shared_library
    subprocess.check_call(['patchelf', '--remove-rpath', so_file])
  File "/home/user/miniconda3/envs/py38/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/home/user/miniconda3/envs/py38/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/home/user/miniconda3/envs/py38/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/user/miniconda3/envs/py38/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'patchelf'

这里面最重要的一句话就是

FileNotFoundError: [Errno 2] No such file or directory: 'patchelf'

它的意思就是:文件错误:找不到patchelf
同样,缺啥装啥,执行如下命令:

$ sudo apt-get install patchelf
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm9
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  patchelf
0 upgraded, 1 newly installed, 0 to remove and 37 not upgraded.
Need to get 53.4 kB of archives.
After this operation, 153 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu focal/universe amd64 patchelf amd64 0.10-2build1 [53.4 kB]
Fetched 53.4 kB in 2s (31.0 kB/s)
Selecting previously unselected package patchelf.
(Reading database ... 128287 files and directories currently installed.)
Preparing to unpack .../patchelf_0.10-2build1_amd64.deb ...
Unpacking patchelf (0.10-2build1) ...
Setting up patchelf (0.10-2build1) ...
Processing triggers for man-db (2.9.1-1) ...

LD_PRELOAD

这是一个动态数据库加载的路径,出现报错如下:

 python
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Python 3.8.13 (default, Mar 28 2022, 11:38:47)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco_py
running build_ext
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

这个并不要紧,只需要执行:unset LD_PRELOAD即可

我用的是ubuntu18.04安装nginx 一般来说我们安装的nginx文件结构大致是这样的: 1. 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下 2. 程序文件在/usr/sbin/nginx 3. 日志放在了/var/log/nginx中 4. 并已经在/etc/init.d/下创建了启动脚本nginx 5. 默认的虚拟主机的目录设置在了/var/www/nginx-default (有的版本 默认的虚拟主机的目录设置在了/var/www, 请参考/etc/nginx/sites-available 文章目录写在开头:一、MuJoCo环境介绍:二、系统平台介绍:三、安装 MuJoCo:3.1 获取许可证3.2 下载源文件四、安装 mujoco-py五、最后解决方案: 写在开头: 本文写在笔者学习了强化学习算法 DQN,PG 和 DDPG 之后 之所以要安装 MuJoCo,是为了尝试 PPO 算法 之前尝试安装 RLBench 去验证学过的几个算法的时候,花费了整整 3 天没有成功,一把辛酸泪~ 所以这次看到 MuJoCo 这个环境也是和机器人相关,想再次尝试一下 希望我踩过的坑可以帮助同道中人少一点痛 用sudo python3 setup.py install不行,会报错。改为 python3.9 setup.py install后成功。怀疑是python版本与mujoco——py的对应问题,不去深究。最终只成功安装mujoco150。主要是要成功安装setup.py报错记录: apt update ERROR: ld.so: object './libadd_c.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libadd_c.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: cd ~/.mujoco # 把安装包下载到该目录 wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz tar -zxvf mujoco210- 参考链接: Failed to load OpenGL: Found 0 GPUs for rendering. Using device 0. Desktop (please complete the following information): OS: ubuntu 20.04 Python Version 3.8.10 Mujoco Version 2.1 mujoco- 安装MujocoMujoco-py的时候踩了不少坑,在Github上找到了解决方法,记录一下。 MujocoMujoco-py安装教程参考如下 Windows10 win10安装mujoco200,mujoco_py2.0.2.9,gym WIN10系统安装gym、mujoco以及Atari MuJoCo.py win10 安装 笔记 Linux Linux系统 Ubuntu18.04 成功安装Mujocomujoco_py 安装流程不再赘述 Linux上的安装基本很顺利,出现问题先检查路径设置和版 编译ROS工程的过程中,因为安装了anaconda导致系统库的路径被覆盖掉,因而报错的时候 runtime library [libssl.so.1.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /home/rw/anaconda3/lib 首先查看路径,可以看到返回结果中,第一个查找路径是anaconda的。 export $PATH bash: export: `/home/rw/anaconda3/bin:/home/rw/anaconda3/condabin:/home/rw/.local/bin:/usr/lo