I'm trying a tutorial on Reinforcement learning wherein I'm currently trying to use gymnasium, mujoco, to train agents. I've installed mujoco and when I try to run the program, the sim window opens for a second and throws this error. Idk what I'm doing wrong.
import gymnasium as gym
import stable_baselines3
import imageio
env=gym.make('Humanoid-v4', render_mode='human')
obs=env.reset()
env.render()
print(obs)
BTW, I'm getting the output of print(obs) which returns a tensor. It's just the sim environment which is throwing this error.
Error Traceback
Traceback (most recent call last):
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\gymnasium\envs\mujoco\mujoco_rendering.py", line 337, in __del__
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\gymnasium\envs\mujoco\mujoco_rendering.py", line 330, in free
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\glfw\__init__.py", line 2358, in get_current_context
AttributeError: 'NoneType' object has no attribute 'glfwGetCurrentContext'
I encountered a similar issue when I was trying to use
Walker2d-v4
. The error message I received was:This led me to believe that the issue might be a compatibility problem between
gymnasium
and the version ofmujoco
you are using. In my case, downgrading themujoco
package resolved the problem. It seems thatgymnasium
might not be fully compatible withmujoco-3.0.0
yet.Here's what you can do to potentially resolve the issue:
install proper version of mujoco package:
Download the corresponding version of mujoco:
You can find the release here.
Extract the downloaded package:
Place it in a directory such as
/home/[user-name]/.mujoco
.Set the necessary environment variables:
Make sure to replace
[your-user-name]
with your actual username.