python 我如何安装gym[box2d]尽管下面的错误?

mqkwyuun  于 2022-10-30  发布在  Python
关注(0)|答案(4)|浏览(262)

当我尝试安装gym[box2d]时,我得到以下错误:我尝试了:pip安装gym[box2d].在anaconda提示我安装了swig和gym[box2d],但我在python3.9环境中编码,它仍然不工作.(我的文本编辑器是pycharm)gym已经安装.和

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:
3xiyfsfu

3xiyfsfu1#

根据Anaconda,您应该使用以下命令

conda install -c conda-forge gym-box2d

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

ffscu2ro

ffscu2ro2#

我想你是用windows来使用openai gym的,它不是官方支持的。gym在windows上的安装不稳定。Linux和mac是官方支持的。我推荐这个视频Installing OpenAI Gym (gym[all]) on Linux, Windows and Mac来安装在Linux上。你可以在windows上使用wsl2,我试过了,而且成功了。
此外,这个文档gym 0.7.4帮助我在使用wsl2(根据文档别名linux服务器)中设置了显示😂。
像box2d这样的单独安装对我来说不起作用。试着像视频中说的那样安装所有的健身房envs(需要很大的空间😪,但没有其他选择)

f3temu5u

f3temu5u3#

我想你可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/,找到pybox2d,下载与你的python版本匹配的版本,然后运行pip install Box2D‑2.3.10‑cp38‑cp38‑win_amd64.whl(改变你的轮子名称!)

kmynzznz

kmynzznz4#

对我来说,解决方案是下载并安装最新稳定版本的Build Tools pour Visual Studio(目前为2022),并在安装过程中选择C++包,然后pip install gym[box2d]就工作了。

相关问题