如何在Google Colab上使用Box 2 D [英] How to use Box 2 D on google colab

查看:217
本文介绍了如何在Google Colab上使用Box 2 D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试以整洁的方式优化OpenAIGym的BipedalWalker. 为了使用Bipedalwalker,必须安装Box 2 D,但是会出现问题.

I am currently trying to optimize OpenAIGym's BipedalWalker with neat. In order to use Bipedalwalker, it is necessary to install Box 2 D, but a problem arises.

为了在Colab上安装Box 2 d,我们首先进行了以下操作.

In order to install Box 2 d on colab, we did the following first.

!apt-get install python-box2d > /dev/null
!pip install gym[Box_2D]
import gym
env = gym.make("BipedalWalker-v2")

但是,这导致了以下错误

However, this caused the following error

/usr/local/lib/python3.6/dist-packages/gym/envs/box2d/lunar_lander.py in <module>()
  2 import numpy as np
  3 
----> 4 import Box2D
  5 from Box2D.b2 import (edgeShape, circleShape, fixtureDef, polygonShape, revoluteJointDef, contactListener)
  6 

ModuleNotFoundError: No module named 'Box2D'

由于在以前的方法中不起作用,因此下次我将Box 2 D放入时,我尝试了以下方法.

Since it did not work in the earlier method, next time I put Box 2 D, I tried the following.

!apt-get -qq -y install swig> /dev/null
!apt-get install build-essential python-dev swig python-pygame subversion > /dev/null
!git clone https://github.com/pybox2d/pybox2d
!python pybox2d/setup.py build 

但是,此方法也发生以下错误.

However, the following error also occurred with this method.

Traceback (most recent call last):File "pybox2d/setup.py", line 151, in <module>
write_init() File "pybox2d/setup.py", line 66, in write_init
license_header = open(os.path.join(source_dir, 'pybox2d_license_header.txt')).read()FileNotFoundError: [Errno 2] No such file or directory: 'Box2D/pybox2d_license_header.txt'

将Box 2d放置在colab上的好方法是什么?

What is a good way to put Box 2d on colab?

推荐答案

下面在colab中为我工作:

Following worked for me in colab:

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

这篇关于如何在Google Colab上使用Box 2 D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆