Render wont close


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

env = gym.make(‘CartPole-v0’)
for _ in range(1000):

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):

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.


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.


I have this same problem, and same specificiations.


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.


I imagine you solved the issue, but I think your problem was that render(close=True) is for old gym versions.

In newer versions you should use env.close(), that’s why the method render doesn’t expect a close input and you get that error.

If you are using code from somwhere else and need that to work, installing an old gym version (i.e. gym==0.9) should make it.