Render wont close


#1

I just started using OpenAI and am just trying to get cartpole working.

env = gym.make(‘CartPole-v0’)
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample())

This opens a new window each time I run it but I cannot close each window unless I close the Jupyter session.

I have tried (as suggested in other forums):

for _ in range(1000):
env.render(close=True)
env.step(env.action_space.sample())

but I get the error: TypeError: render() got an unexpected keyword argument ‘close’

This is: ubuntu 16.04, anaconda w/python 3.6 and a gpu (which seems to work fine for other uses). THe only thing I have done is downgrade piglet (as suggested elsewhere) because I was getting errors.


#2

I just deleted the “close=True”, seems to work after that. Not sure what the reason for this is though. Maybe someone else will have useful info.


#3

I have this same problem, and same specificiations.


#4

This isn’t the best solution but I have been using xkill in the command line, it will close all the gym windows, but next time you run that Jupyter cell the kernel will have to restart.