报错如下
Building wheels for collected packages: box2d-kengz
Building wheel for box2d-kengz (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 66.0.0).
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-38
creating build\lib.win-amd64-cpython-38\Box2D
copying library\Box2D\Box2D.py -> build\lib.win-amd64-cpython-38\Box2D
copying library\Box2D\__init__.py -> build\lib.win-amd64-cpython-38\Box2D
creating build\lib.win-amd64-cpython-38\Box2D\b2
copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-cpython-38\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-kengz
Running setup.py clean for box2d-kengz
Failed to build box2d-kengz
Installing collected packages: box2d-kengz
Running setup.py install for box2d-kengz ... error
error: subprocess-exited-with-error
× Running setup.py install for box2d-kengz did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
Using setuptools (version 66.0.0).
running install
D:\Anaconda3\envs\RL\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-38
creating build\lib.win-amd64-cpython-38\Box2D
copying library\Box2D\Box2D.py -> build\lib.win-amd64-cpython-38\Box2D
copying library\Box2D\__init__.py -> build\lib.win-amd64-cpython-38\Box2D
creating build\lib.win-amd64-cpython-38\Box2D\b2
copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-cpython-38\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: legacy-install-failure
× Encountered error while trying to install package.
╰─> box2d-kengz
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
可以看到这是没有swig.exe导致的:
解决方案
安装swig:官网:https://www.swig.org/download.html
可以参考:《Win10下安装swig》
swig-win-4.1.1.zip分享:
链接:https://pan.baidu.com/s/1bCw9GeM7q_1PEQuPkk0zzQ?pwd=2srk
提取码:2srk
安装完swig后,成功安装box2d-kengz: