本文主要是介绍【Reinforcement Learning】Ubuntu中mujoco210 mujoco_py D4RL安装及错误解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Ubuntu中mujoco210 mujoco_py D4RL安装及错误解决
本文根据一篇知乎文章链接在此进行配置,记录在配置过程中遇到的一些问题,原文作者的教程很详细,在此对原作者表示感谢~
- 直接进行知乎原文的第2.2 有效安装过程(避坑)
2.注意上文中各行代码的作用
原文作者的代码有一点点小问题,我在注释中指出,要注意甄别
**注意/.mujoco是隐藏文件夹,在界面中可以打开显示隐藏文件的开关**
# 下载地址 https://github.com/deepmind/mujoco/releases/tag/2.1.0
cd ~/Downloads/
wget https://github.com/deepmind/mujoco/releases/download/2.1.0/mujoco210-linux-x86_64.tar.gz
mv mujoco210-linux-x86_64.tar.gz mujoco210 #这里相当于重命名
tar -zxvf mujoco210-linux-x86_64.tar.gz #这里有问题 应解压重命名后的文件
mkdir ~/mujoco #这里应改为 mkdir ~/.mujoco
cp -r mujoco210 ~/.mujoco #复制到~/.mujoco中
# 添加环境变量
sudo gedit ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.mujoco/mujoco210/bin
export MUJOCO_KEY_PATH=~/.mujoco${MUJOCO_KEY_PATH}
source ~/.bashrc# 测试
cd ~/.mujoco/mujoco210/bin/
./simulate ../model/humanoid.xml
其余按照原作者的内容进行安装
3.在安装mujoco_py时,我首先遇到作者未出现的报错
anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/__init__.py", line 2, in <module>from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoExceptionFile "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 504, in <module>cymj = load_cython_ext(mujoco_path)File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 110, in load_cython_extcext_so_path = builder.build()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 226, in buildbuilt_so_file_path = self._build_impl()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 296, in _build_implso_file_path = super()._build_impl()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 239, in _build_impldist.ext_modules = cythonize([self.extension])File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonizecythonize_one(*args)File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_oneraise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx
>>> import mujoco_py
Compiling /home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx
performance hint: anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx:67:5: Exception check on 'c_warning_callback' will always require the GIL to be acquired.
Possible solutions:1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.2. Use an 'int' return type on the function to allow an error code to be returned.
performance hint: anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx:104:5: Exception check on 'c_error_callback' will always require the GIL to be acquired.
Possible solutions:1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.2. Use an 'int' return type on the function to allow an error code to be returned.Error compiling Cython file:
------------------------------------------------------------
...See c_warning_callback, which is the C wrapper to the user defined function'''global py_warning_callbackglobal mju_user_warningpy_warning_callback = warnmju_user_warning = c_warning_callback^
------------------------------------------------------------anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.Error compiling Cython file:
------------------------------------------------------------
...See c_warning_callback, which is the C wrapper to the user defined function'''global py_error_callbackglobal mju_user_errorpy_error_callback = err_callbackmju_user_error = c_error_callback^
------------------------------------------------------------anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/__init__.py", line 2, in <module>from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoExceptionFile "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 504, in <module>cymj = load_cython_ext(mujoco_path)File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 110, in load_cython_extcext_so_path = builder.build()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 226, in buildbuilt_so_file_path = self._build_impl()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 296, in _build_implso_file_path = super()._build_impl()File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/builder.py", line 239, in _build_impldist.ext_modules = cythonize([self.extension])File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonizecythonize_one(*args)File "/home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_oneraise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /home/yangsen/anaconda3/envs/myRL/lib/python3.9/site-packages/mujoco_py/cymj.pyx
解决方法:更换Cython版本
参考文章
pip install Cython==3.0.0a10
更换版本后继续 import mojoco_py出现知乎文章中提及的问题,按照原文作者的方法可以解决
4.祝安装成功!
这篇关于【Reinforcement Learning】Ubuntu中mujoco210 mujoco_py D4RL安装及错误解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!