OpenAI Gym environment cannot be loaded in Google Colab

Viewed 3086

I'm trying to train a DQN in google colab so that I can test the performance of the TPU. Unfortunately, I get the following error:

import gym
env = gym.make('LunarLander-v2')

AttributeError: module 'gym.envs.box2d' has no attribute 'LunarLander'

I know this is a common error, and I had this before on my local machine. I was able to fix it with commands like:

!pip install box2d box2d-kengz
!pip install Box2D
!pip install -e '.[box2d]'

While this worked on my local machine, on google colab is it not. I can't get rid of the error. Does anyone have a solution?

1 Answers

On a fresh colab, I simply installed box2d-py via

!pip3 install box2d-py

and it worked.

Try it on a new colab it should work.

Related