我正在尝试在 Google Colab 中使用 Box2D 和 TensorFlow 编写强化学习模型。我对所有内容都有一个简单的单行安装命令,因为我发现每当我尝试进行多行安装时,Colab 都会中断,甚至 Gymnasium 主页面也将
pip install Box2D
作为安装它的正确方法。
每当我尝试安装它时,都会收到此错误:
!pip install tensorflow[and-cuda] stable-baselines gym Box2D
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Building wheel for Box2D (setup.py) ... error
ERROR: Failed building wheel for Box2D
Running setup.py clean for Box2D
Failed to build Box2D
ERROR: Could not build wheels for Box2D, which is required to install pyproject.toml-based projects
我在网上找到的每个解决方案都不起作用,但似乎都有同样的问题。我该如何解决它?
我找到了修复方法,安装gymnasium后的以下代码对我有用:
!apt-get install build-essential
!apt-get install swig
!apt-get install python-box2d
!pip install gym[box2d]