我已经在gymnasium环境中工作了几个星期,通过在笔记本中使用以下命令,我在Google Colab中没有遇到任何问题:
pip3 install gymnasium[box2d]
但是,在不更改任何内容的情况下,我尝试再次运行该命令,但它突然停止正确安装 Box2d。
我得到以下输出:
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting gymnasium[box2d]
Downloading gymnasium-0.28.1-py3-none-any.whl (925 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 925.5/925.5 kB 19.7 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.21.0 in /usr/local/lib/python3.10/dist-packages (from gymnasium[box2d]) (1.22.4)
Collecting jax-jumpy>=1.0.0 (from gymnasium[box2d])
Downloading jax_jumpy-1.0.0-py3-none-any.whl (20 kB)
Requirement already satisfied: cloudpickle>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from gymnasium[box2d]) (2.2.1)
Requirement already satisfied: typing-extensions>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from gymnasium[box2d]) (4.5.0)
Collecting farama-notifications>=0.0.1 (from gymnasium[box2d])
Downloading Farama_Notifications-0.0.4-py3-none-any.whl (2.5 kB)
Collecting box2d-py==2.3.5 (from gymnasium[box2d])
Downloading box2d-py-2.3.5.tar.gz (374 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 374.4/374.4 kB 11.0 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting pygame==2.1.3 (from gymnasium[box2d])
Downloading pygame-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.7/13.7 MB 28.2 MB/s eta 0:00:00
Collecting swig==4.* (from gymnasium[box2d])
Downloading swig-4.1.1-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 13.0 MB/s eta 0:00:00
Building wheels for collected packages: box2d-py
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-py (setup.py) ... error
ERROR: Failed building wheel for box2d-py
Running setup.py clean for box2d-py
Failed to build box2d-py
ERROR: Could not build wheels for box2d-py, which is required to install pyproject.toml-based projects
我尝试更改gymnasium的版本,甚至只是从gym安装,但错误仍然存在。我不知道发生了什么事,因为昨天我对此没有任何问题。
我遇到了同样的问题。经过一番挖掘和大量试验和错误后,我能够通过首先运行
pip install swig
来让它工作。
希望有帮助。
以下对我有用
!pip install -q swig
!pip install -q gymnasium[box2d]
我没有使用 Google Colab,但遇到了同样的问题,但是这个命令解决了我的问题:
pip install wheel setuptools pip --upgrade
然后我就可以安装了:
pip install swig
pip install gymnasium[box2d]