安装时总会报错
Building wheels for collected packages: box2d-py
Building wheel for box2d-py (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Using setuptools (version 68.0.0).
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\Box2D
copying library\Box2D\Box2D.py -> build\lib.win-amd64-cpython-311\Box2D
copying library\Box2D\__init__.py -> build\lib.win-amd64-cpython-311\Box2D
creating build\lib.win-amd64-cpython-311\Box2D\b2
copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-cpython-311\Box2D\b2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D\Box2D.i to Box2D\Box2D_wrap.cpp
swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library\Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D\Box2D_wrap.cpp Box2D\Box2D.i
error: command 'swig.exe' failed: None
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
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
解决办法:
在安装box2d-py之前要确保pip
和swig
已经正常安装,
大部分是因为缺少swig
!!
安装好swig后就可以顺利安装gymnasium[box2d]
了