mac179
mac179

Reputation: 2010

How to install mujoco-py on windows?

I tried running the following code to test the HalfCheetah-v2 environment:

import gym
env = gym.make('HalfCheetah-v2')

But this gives me the following error: ModuleNotFoundError: No module named 'mujoco_py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    env = gym.make('HalfCheetah-v2')
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 145, in make
    return registry.make(id, **kwargs)
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 90, in make
    env = spec.make(**kwargs)
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 59, in make
    cls = load(self.entry_point)
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\site-packages\gym\envs\registration.py", line 18, in load
    mod = importlib.import_module(mod_name)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\site-packages\gym\envs\mujoco\__init__.py", line 1, in <module>
    from gym.envs.mujoco.mujoco_env import MujocoEnv
  File "C:\Users\Amine\AppData\Roaming\Python\Python36\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'. (HINT: you need to install mujoco_py, and also perform the setup instructions here: https://github.com/openai/mujoco-py/.)

I just could not find any resource/website that explains step-by-step how to install it on windows. I have the other classic environments such as CartPole and MountainCar from classic control. However, the ones from mujoco are the most used in papers.

Upvotes: 4

Views: 10162

Answers (1)

desertnaut
desertnaut

Reputation: 60317

HalfCheetah-v2 (and v1, actually) is a MuJoCo environment; this means that, apart from (and before) mujoco-py, you should first install MuJoCo itself. These environments were not meant for general use, as MuJoco was under a commercial license - at least until today (literally...), that DeepMind announced that they have just bought MuJoCo, and they make it freely available to everyone.

Nevertheless, in the requirements section of the mujoco-py repo, it is clearly mentioned:

Windows support has been DEPRECATED and removed in 2.0.2.0. One known good past version is 1.50.1.68.

so no big surprise that there is not any installation guide for Windows.

In any case, you may have a look at the post Install OpenAI Gym with Box2D and Mujoco in Windows 10 (2019); keeping in mind the recommended mujoco-py version above, you may have some success (needless to say, the "easy" option described toward the end, pip install gym[all], will not work).

Other possibly useful resources:

Upvotes: 5

Related Questions