error.MujocoDependencyError & mujoco_py.error.MujocoDependencyError 解决方案

问题描述

今天运行mujoco系列代码时,出现了如下错误:

Traceback (most recent call last):
  File "run_mujoco.py", line 5, in
    from half_cheetah import *
  File "/root/code/ioc/control/baselines/ppoc_int/half_cheetah.py", line 2, in
    from gym.envs.mujoco import HalfCheetahEnv as HalfCheetahEnv_
  File "/opt/conda/envs/interest_cs/lib/python3.6/site-packages/gym/envs/mujoco/__init__.py", line 1, in
    from gym.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv  # isort:skip
  File "/opt/conda/envs/interest_cs/lib/python3.6/site-packages/gym/envs/mujoco/mujoco_env.py", line 16, in
    import mujoco_py
  File "/opt/conda/envs/interest_cs/lib/python3.6/site-packages/mujoco_py/__init__.py", line 2, in
    init_config()
  File "/opt/conda/envs/interest_cs/lib/python3.6/site-packages/mujoco_py/config.py", line 33, in init_config
    raise error.MujocoDependencyError('To use MuJoCo, you need to either populate ~/.mujoco/mjkey.txt and ~/.mujco/mjpro131, or set the MUJOCO_PY_MJKEY_PATH and MUJOCO_PY_MJPRO_PATH environment variables appropriately. Follow the instructions on https://github.com/openai/mujoco-py for where to obtain these.')
mujoco_py.error.MujocoDependencyError: To use MuJoCo, you need to either populate ~/.mujoco/mjkey.txt and ~/.mujco/mjpro131, or set the MUJOCO_PY_MJKEY_PATH and MUJOCO_PY_MJPRO_PATH environment variables appropriately. Follow the instructions on https://github.com/openai/mujoco-py for where to obtain these.

相关包的版本如下:

gym==0.9.3
mujoco-py==0.5.1

解决方案

通过参考 

https://www.jianshu.com/p/a0a87ba6ef12

打开 /opt/conda/envs/interest_cs/lib/python3.6/site-packages/mujoco_py/config.py文件,可以看到mjkey.txt与mjpro131的默认安装位置:

从官网分别下载mjkey.txt:License 

mjpro131:Download

error.MujocoDependencyError & mujoco_py.error.MujocoDependencyError 解决方案_第1张图片

将它们分别放入config.py对应的文件夹中(注意:mjpro131需要解压)

然后再次运行相关代码,可以发现之前的错误已经得到解决。

你可能感兴趣的:(bug解决方案,python,开发语言)