6

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?

spadel
  • 998
  • 2
  • 16
  • 40

2 Answers2

3

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.

Valentin Macé
  • 1,150
  • 1
  • 10
  • 25
1

You need to execute at the beginning a cell with the code:

!sudo apt-get install swig build-essential python-dev python3-dev

This should solve your problem and you will be able to install this library in google colab

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
dangob
  • 56
  • 2