问题
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.
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'
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'
What is a good way to put Box 2d on colab?
回答1:
Following worked for me in colab:
!pip install box2d-py
!pip install gym[Box_2D]
import gym
env = gym.make("BipedalWalker-v2")
来源:https://stackoverflow.com/questions/52611672/how-to-use-box-2-d-on-google-colab