我已经跟随this method运行了一个box2d环境,而没有在google colab中渲染它,
!apt-get install python-box2d
!pip install box2d-py
!pip install gym[Box_2D]
import gym
env = gym.make("BipedalWalker-v2")
但它显示了这个
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-box2d is already the newest version (2.3.2~dfsg-2).
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.
Requirement already satisfied: box2d-py in /usr/local/lib/python3.6/dist-packages (2.3.8)
Requirement already satisfied: gym[Box_2D] in /usr/local/lib/python3.6/dist-packages (0.15.3)
WARNING: gym 0.15.3 does not provide the extra 'box_2d'
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.12.0)
Requirement already satisfied: pyglet<=1.3.2,>=1.2.0 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.3.2)
Requirement already satisfied: numpy>=1.10.4 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.17.3)
Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.3.1)
Requirement already satisfied: cloudpickle~=1.2.0 in /usr/local/lib/python3.6/dist-packages (from gym[Box_2D]) (1.2.2)
Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from pyglet<=1.3.2,>=1.2.0->gym[Box_2D]) (0.16.0)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-62ca95674145> in <module>()
3 get_ipython().system('pip install gym[Box_2D]')
4 import gym
----> 5 env = gym.make("BipedalWalker-v2")
3 frames
/usr/local/lib/python3.6/dist-packages/gym/envs/registration.py in load(name)
16 mod_name, attr_name = name.split(":")
17 mod = importlib.import_module(mod_name)
---> 18 fn = getattr(mod, attr_name)
19 return fn
20
AttributeError: module 'gym.envs.box2d' has no attribute 'BipedalWalker'
我也试着从pip pip install Box2D
安装这个box2d,但它没有安装在colab中。如何在google colag中安装和运行box2d gym环境?
3条答案
按热度按时间ymdaylpp1#
我可以用
!pip3 install box2d-py==2.3.8
来实现它。v1l68za42#
请创建一个新的Colab笔记本,点击文件-〉新建笔记本。在新的(新鲜的)Colab上执行以下操作:
gym默认安装在新笔记本中,但是您必须安装box 2d-py和gym[Box_2D]。如果遇到错误,请关闭当前笔记本。只需使用一个新的笔记本电脑(非常重要),并继续上述程序的pip安装。会成功的!
l3zydbqr3#
这对我很有效。在运行这些代码之前,请确保在Google Colab notebook中重新启动运行时:
然后在另一个细胞中运行这个
希望这有帮助!