尽管出现以下错误,我如何安装 gym[box2d]?

how can i install gym[box2d] despite errors below?

当我尝试安装 gym[box2d] 时出现以下错误: 我试过:pip install gym[box2d]。 在 anaconda 提示符下,我安装了 swig 和 gym[box2d],但我在 python3.9 env 中编码,但它仍然无法正常工作。(我的文本编辑器是 pycharm) 健身房已经 installed.and

ERROR: Command errored out with exit status 1:
   command: 'C:\Users\hooman\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\hoom
an\AppData\Local\Temp\pip-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\setup.py'"'"'; __file__='"'"'C:\Users\hooman\AppData\Local\Temp\pi
p-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else
 io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exe
c'"'"'))' bdist_wheel -d 'C:\Users\hooman\AppData\Local\Temp\pip-wheel-va_dgazk'
       cwd: C:\Users\hooman\AppData\Local\Temp\pip-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\
  Complete output (16 lines):
  Using setuptools (version 58.2.0).
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\Box2D
  copying library\Box2D\Box2D.py -> build\lib.win-amd64-3.9\Box2D
  copying library\Box2D\__init__.py -> build\lib.win-amd64-3.9\Box2D
  creating build\lib.win-amd64-3.9\Box2D\b2
  copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-3.9\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_wr
ap.cpp Box2D\Box2D.i
  error: command 'swig.exe' failed: None
  ----------------------------------------
  ERROR: Failed building wheel for box2d-py
  Running setup.py clean for box2d-py
Failed to build box2d-py
Installing collected packages: box2d-py
    Running setup.py install for box2d-py ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\hooman\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\ho
oman\AppData\Local\Temp\pip-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\setup.py'"'"'; __file__='"'"'C:\Users\hooman\AppData\Local\Temp\
pip-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) el
se io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'e
xec'"'"'))' install --record 'C:\Users\hooman\AppData\Local\Temp\pip-record-yz4t1mq0\install-record.txt' --single-version-externally-managed --compile --install-he
aders 'C:\Users\hooman\AppData\Local\Programs\Python\Python39\Include\box2d-py'
         cwd: C:\Users\hooman\AppData\Local\Temp\pip-install-_vo0km5i\box2d-py_aea38b0da25341cf93e6a6c9d4b9d296\
    Complete output (16 lines):
    Using setuptools (version 58.2.0).
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\Box2D
    copying library\Box2D\Box2D.py -> build\lib.win-amd64-3.9\Box2D
    copying library\Box2D\__init__.py -> build\lib.win-amd64-3.9\Box2D
    creating build\lib.win-amd64-3.9\Box2D\b2
    copying library\Box2D\b2\__init__.py -> build\lib.win-amd64-3.9\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
    ----------------------------------------
ERROR: Command errored out with exit status 1: 

根据Anaconda,你应该使用下面的命令

conda install -c conda-forge gym-box2d

但您仍然可以只安装 gymfrom gym.envs import box2d

我认为您正在使用 windows 来使用不受官方支持的 openai gym。 windows 的健身房安装不稳定。 Linux 和 mac 得到官方支持。我推荐此视频 Installing OpenAI Gym (gym[all]) on Linux, Windows and Mac 用于在 Linux 中安装。你可以在 windows 中使用 wsl2,我已经试过了。

此文档 gym 0.7.4 还帮助我设置了使用 wsl2 的显示(根据文档别名 linux 服务器)。

像 box2d 这样的单独安装对我不起作用。尝试按照视频中的说明安装所有健身房环境(需要很多 space 但没有其他选择)