py3 安装 box2d-py

时间:2024-04-12 16:26:22

直接 pip 安装试试

>>>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple box2d-py
...
 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

  ----------------------------------------
  Failed building wheel for box2d-py
  ...

只好去找 wheel
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pybox2d

>>> pip install Box2D-2.3.2-cp36-cp36m-win_amd64.whl

测试下面这段代码:

import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample())

py3 安装 box2d-py