mujoco-py
mujoco-py copied to clipboard
render window does not close
Describe the bug This is the code I am running.
#Importing OpenAI gym package and MuJoCo engine
import gym
import mujoco_py
#Setting MountainCar-v0 as the environment
env = gym.make('HalfCheetah-v2')
# env = gym.make('MountainCar-v0')
#Sets an initial state
env.reset()
# Rendering our instance 300 times
for _ in range(300):
#renders the environment
env.render()
#Takes a random action from its action space
# aka the number of unique actions an agent can perform
env.step(env.action_space.sample())
env.close()
It runs fine, but then the render window doesn't close. Even when I do env.close() again, it doesn't close. I am runnning the code on jupyter notebook, in ubuntu. When I try to manually click close, the window becomes non-responsive and the dialog box pops up where I click 'Force Quit'. The window closes but then the jupyter kernel restarts.
I don't face the problem when I use MountainCar instead of the MuJoCo environment.
I also experience the same issue on Jupyter
I have the same issue, I fixed it by:
import glfw
glfw.terminate()
@kaigett it works - you'll need to restart the kernel though. :)
env = gym.make("CarRacing-v0")
env.reset()
for i in range(1000):
env.render()
env.step(env.action_space.sample())
env.reset()
env.close()
This worked for me.
I think CarRacing is in Box2d environment but not MUJOCO. MUJOCO requires glfw.terminate() for closing the window.