简体   繁体   中英

Problems pip installing Box2D

I'm learning Reinforcement learning and I'm having the following errors.

Error(1) = I can't set up the 'CarRacing-v0' gym environment without Box2D

Error(2) = I can't pip install the Box2D module.

Does someone know how to interpret these errors and help me fix this?


在此处输入图片说明

在此处输入图片说明

Edit:

When trying to pip install box2d-py I get this error:

在此处输入图片说明

Windows users need to do as follows:

  • Download SWIG with the prebuilt executable and extract somewhere on your PC. Please note : I don't think SWIG 4.0 is compatible with Box2D yet, at time of writing SWIG 3.0.12 must be used.
  • Add the SWIG directory containing swig.exe to system PATH environment variable.
  • Install Microsoft Visual C++ 14.0. Get it with " Microsoft Visual C++ Build Tools ".
  • pip install box2d
  • pip install box2d-py

Mac users should try:

  1. brew install swig
  2. pip install box2d-py
  3. pip install box2d

terminates without errors under macOS Mojave (10.14)

根据gymsetup.py ,它尝试导入的Box2D似乎来自可选的依赖项box2d-py ,因此您需要运行pip install box2d-py

对于 Ubuntu 18.04,以下解决了我的健身房和月球着陆器问题:

pip3 install box2d-py

I know this does not solve the problem but after trying for an entire day I ended up running the game using Google Colab Notebooks . Only problem with that is it's a bit hard to render the screen but there is a post on the topic here .

For Ubuntu 20.04.3, I had to run the following:

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

before installing box2d-py .

pip install Box2D

it will work 100%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM