Farama-Foundation / MO-Gymnasium

Multi-objective Gymnasium environments for reinforcement learning
http://mo-gymnasium.farama.org/
MIT License
266 stars 36 forks source link

Different MuJoCo requirements when installing mo-gymnasium[all] vs mo-gymnasium[mujoco] #71

Closed gresavage closed 1 year ago

gresavage commented 1 year ago

Background

While trying to run Hopper I ran into the following error:

  File "/opt/conda/envs/saferl_env/lib/python3.8/site-packages/mo_gymnasium/envs/mujoco/hopper.py", line 23, in __init__
    super().__init__(**kwargs)
  File "/opt/conda/envs/saferl_env/lib/python3.8/site-packages/gymnasium/envs/mujoco/hopper_v4.py", line 206, in __init__
    MujocoEnv.__init__(
  File "/opt/conda/envs/saferl_env/lib/python3.8/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 333, in __init__
    super().__init__(
  File "/opt/conda/envs/saferl_env/lib/python3.8/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 52, in __init__
    self._initialize_simulation()  # may use width and height
  File "/opt/conda/envs/saferl_env/lib/python3.8/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 351, in _initialize_simulation
    self.model = mujoco.MjModel.from_xml_path(self.fullpath)
ValueError: XML Error: global coordinates no longer supported. To convert existing models, load and save them in MuJoCo 2.3.3 or older
Element 'compiler', line 2

After some digging, I discovered that MuJoCo 2.3.6 was installed in my environment. When I looked into pyproject.toml for mo-gymnasium I found that the requirements for MuJoCo were different depending on how the user chooses to install optional packages for mo-gymnasium

Specifically compare line 37 to line 50 in pyproject.toml. Line 37 (mo-gymnasium[mujoco]) allows any MuJoCo version later than 2.3.0, while Line 50 (mo-gymnasium[all]) strictly enforces MuJoCo==2.3.2

Steps to reproduce

  1. Install optional MuJoCo dependencies for gymnasium and mo-gymnasium:

    pip install gymnasium[mujoco] mo-gymnasium[mujoco]

    gymnasium will try to install mujoco 2.3.6, and pips dependency solver will not see a conflict as this satisfies mo-gymnasiums optional dependency variant for mujoco

  2. Try to run a Hopper (or other) experiment

Solution

Change the MuJoCo version requirements for mo-gymnasium[mujoco] to match mo-gymnasium[all], i.e. change line 37 in pyproject.toml:

 mujoco = ["mujoco ==2.3.2", "imageio >=2.14.1"]
LucasAlegre commented 1 year ago

Thanks! Fixed at 32f34ad1e851cfc1102ef99c4b3fbf5b55fe83c9