“ gym.envs.box2d”在COLAB上的RL问题没有属性“ LunarLander”

问题描述

openai-gym中使用env“ LunarLander-v2”可以在Colab中做什么。我已经安装了 Box2D Box2d-py ,但总是返回相同的错误

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

在我的本地机器上,此段落有效,但在Colab上无效。 有什么解决方案?

版本: Python:3.6-Gym:0.17.2-Box2D:2.3.10

解决方法

重要的部分是创建一个新的 Colab notebook,点击 File -> New notebook。在一个新的(新鲜的)Colab 上执行这些:

!pip3 install box2d-py
!pip3 install gym[Box_2D]
import gym
env = gym.make("LunarLander-v2")

新笔记本中默认安装了gym,但是您必须安装box2d-py 和gym[Box_2D]。如果您遇到 'gym.envs.box2d' has no attribute 'LunarLander' 错误,请关闭当前笔记本。只需使用新笔记本并继续上述 pip 安装过程。它会起作用!

,

刚安装 Box2D 就解决了我的问题

pip install Box2D