来自builder.py

时间:2018-08-06 17:20:35

标签: python path bin openai-gym

我当前在Visual Studio代码1.25.1中使用Python 3.5.4

我正在尝试使用openai体育馆,并试图使用MuJoCo软件包。我已经在MuJoCo成功注册了一个帐户,并为win64下载了mjpro150。使用openai提供的最基本的示例,我使用以下代码来尝试启动Humanoid-v2任务:

import gym
env = gym.make('Humanoid-v2')
for i_episode in range(20):
observation = env.reset()
for t in range(100):
    env.render()
    print(observation)
    action = env.action_space.sample()
    observation, reward, done, info = env.step(action)
    if done:
        print("Episode finished after {} timesteps".format(t+1))
        break

在终端上运行后,我收到输出:

PS C:\Users\Adam9\Documents\Machine Learning\Open AI Environments> & python 
"c:/Users/Adam9/Documents/Machine Learning/Open AI Environments/Humanoid.py"
Traceback (most recent call last):
  File "c:/Users/Adam9/Documents/Machine Learning/Open AI 
  Environments/Humanoid.py", line 2, in <module>
    env = gym.make('Humanoid-v2')
  File "C:\Python35\lib\site-packages\gym\envs\registration.py", line 167, in 
  make
    return registry.make(id)
  File "C:\Python35\lib\site-packages\gym\envs\registration.py", line 119, in 
  make
    env = spec.make()
  File "C:\Python35\lib\site-packages\gym\envs\registration.py", line 85, in 
  make
    cls = load(self._entry_point)
  File "C:\Python35\lib\site-packages\gym\envs\registration.py", line 14, in 
  load
    result = entry_point.load(False)
  File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 2405, 
  in load
    return self.resolve()
  File "C:\Python35\lib\site-packages\pkg_resources\__init__.py", line 2411, 
  in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "C:\Python35\lib\site-packages\gym\envs\mujoco\__init__.py", line 1, 
  in <module>
    from gym.envs.mujoco.mujoco_env import MujocoEnv
  File "C:\Python35\lib\site-packages\gym\envs\mujoco\mujoco_env.py", line 
  11, in <module>
    import mujoco_py
  File "C:\Python35\lib\site-packages\mujoco_py\__init__.py", line 1, in 
  <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, 
    MujocoException
  File "C:\Python35\lib\site-packages\mujoco_py\builder.py", line 468, in 
  <module>
    cymj = load_cython_ext(mjpro_path)
  File "C:\Python35\lib\site-packages\mujoco_py\builder.py", line 78, in 
  load_cython_ext
    "set %s=%s;%%%s%%" % (var, lib_path, var))
Exception: Please add mujoco library to your PATH:
set Path=C:\Users\Adam9\.mujoco\mjpro150\bin;%Path%

我要解决的问题是“异常:请将mujoco库添加到您的PATH:”,它是builder.py第78行的输出,对于上下文行64-81是:

lib_path = os.path.join(mjpro_path, "bin")
if sys.platform == 'darwin':
    Builder = MacExtensionBuilder
elif sys.platform == 'linux':
    _ensure_set_env_var("LD_LIBRARY_PATH", lib_path)
    if os.getenv('MUJOCO_PY_FORCE_CPU') is None and get_nvidia_lib_dir() is 
    not None:
        _ensure_set_env_var("LD_LIBRARY_PATH", get_nvidia_lib_dir())
        Builder = LinuxGPUExtensionBuilder
    else:
        Builder = LinuxCPUExtensionBuilder
elif sys.platform.startswith("win"):
    var = "Path"
    if var not in os.environ or lib_path not in os.environ[var].split(";"):
        raise Exception("Please add mujoco library to your PATH:\n"
                        "set %s=%s;%%%s%%" % (var, lib_path, var))
    Builder = WindowsExtensionBuilder
else:
    raise RuntimeError("Unsupported platform %s" % sys.platform)

我已经在用户(Adam9)中添加了.mujoco文件夹,并在bin文件夹中添加了mjkey.txt。我还在Python文件夹的site-packages文件夹中包含了mujoco库的路径。添加的所有路径为:

C:\ Users \ Adam9.mujoco \ mjpro150 \ bin

C:\ Users \ Adam9.mujoco \ mjpro150 \ bin;%Path%

C:\ Python35 \ Lib \ site-packages \ mujoco_py \ mujoco \ bin

C:\ Python35 \ Lib \ site-packages \ mujoco_py \ mujoco

C:\ Python35 \ Lib \ site-packages \ mujoco_py

C:\ Python35 \ Lib \ site-packages \ Cython

所有路径都同时反映在用户变量和系统变量中。列出的“ mujoco”文件夹是从MuJoCo网站下载的“ mjpro150”文件夹的重命名。我应该如何解决这个问题?

0 个答案:

没有答案