python - OpenAI gym mujoco ImportError : No module named 'mujoco_py.mjlib'

标签 python openai-gym

我尝试在 openAi gym 中运行这段代码。但它不能。

import mujoco_py
import gym
from os.path import dirname

env = gym.make('Hopper-v1')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample()) 

错误信息:

/Users/yunfanlu/anaconda/envs/py35/bin/python3.5 /Users/yunfanlu/WorkPlace/OpenAIGym/OpenGymL/c.py
[2017-07-23 17:17:15,633] Making new env: Hopper-v1
Traceback (most recent call last):
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/mujoco/mujoco_env.py", line 12, in <module>
    from mujoco_py.mjlib import mjlib
ImportError: No module named 'mujoco_py.mjlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/yunfanlu/WorkPlace/OpenAIGym/OpenGymL/c.py", line 15, in <module>
    env = gym.make('Hopper-v1')
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/registration.py", line 119, in make
    env = spec.make()
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/registration.py", line 85, in make
    cls = load(self._entry_point)
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/registration.py", line 17, in load
    result = entry_point.load(False)
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 2258, in load
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 2264, in resolve
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/mujoco/__init__.py", line 1, in <module>
    from gym.envs.mujoco.mujoco_env import MujocoEnv
  File "/Users/yunfanlu/anaconda/envs/py35/lib/python3.5/site-packages/gym/envs/mujoco/mujoco_env.py", line 14, in <module>
    raise error.DependencyNotInstalled("{}. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)".format(e))
gym.error.DependencyNotInstalled: No module named 'mujoco_py.mjlib'. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)

Process finished with exit code 1

我的电脑环境:

操作系统:macOS python: python3.5 (conda 环境)

我已经安装了“pip install 'gym[all]'”并安装了 mujoco。

➜  .mujoco tree
.
├── LICENSE.txt
├── mjkey.txt
└── mjpro150

我可以运行 mujoco 的例子。成功了。

(py35) ➜  OpenGymL python body_interaction.py 
Creating window glfw

最佳答案

我有同样的问题,这是由于安装了最新的 mujoco-py 版本,该版本与 gym 包的 mujoco 环境不兼容。

问题仍未解决,其详细信息已在 #80 中捕获.正如 machinaut 评论的那样,更新已在路线图上,您可以同时使用 0.5.7 版。

pip install mujoco-py==0.5.7

关于python - OpenAI gym mujoco ImportError : No module named 'mujoco_py.mjlib' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45263566/

相关文章:

python - 如何将行的值转换为列

python - OpenAI 将自定义游戏集成到健身房环境中

openai-gym - FrozenLake OpenAI-Gym 环境如何在没有中间奖励的情况下解决?

python - 数据收集时的IP阻止

Python根据给定的键组合2个列表

python - 如何在 mac 上为 python 安装 libsvm?

python - Stablebaselines3 自定义健身房记录奖励

python - OpenCV + 健身房复古 : Invalid number of channels in input image

reinforcement-learning - 为什么 Stable-Baselines3 evaluate_policy() 函数永远不会完成/完成?

python - 重新实现QWebView复制链接