pythonvisual-studio-codeinstall.packages

Problems installing stable-baselines3[extra] and gym[all]


I want to install stable-baselines3[extra] and gym[all] in vs code but I get these errors:

pip install gym[all]

Building wheels for collected packages: box2d-py
Building wheel for box2d-py (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for box2d-py (pyproject.toml) did not run 
successfully.
│ exit code: 1
╰─> [16 lines of output]
  Using setuptools (version 67.7.2).
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-310
  creating build\lib.win-amd64-cpython-310\Box2D
  copying library\Box2D\Box2D.py -> build\lib.win-amd64-cpython- 
  310\Box2D
  copying library\Box2D\__init__.py -> build\lib.win-amd64-cpython- 
  310\Box2D
  creating build\lib.win-amd64-cpython-310\Box2D\b2
  copying library\Box2D\b2\__init__.py -> build\lib.win-amd64- 
  cpython-310\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
  Failed to build box2d-py
  ERROR: Could not build wheels for box2d-py, which is required 
  to 
  install pyproject.toml-based projects

pip install stable-baselines3[extra]

  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
  error in gym setup command: 'extras_require' must be a dictionary 
  whose values are strings or lists of strings containing valid 
  project/version requirement specifiers.
  [end of output]

  note: This error originates from a subprocess, and is likely 
  not 
  a problem with pip.
  error: subprocess-exited-with-error

  × Getting requirements to build 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.

I have tried: pip install swig without any success. How can I fix it? I have tried installing them on Jupyter Notebook and Spyder as well on three different pcs but nothing works. I would be grateful if someone could help me.


Solution

  • As shown in the Stable Baselines sample notebook, you can use:

    !pip install "stable-baselines3[extra]>=2.0.0a4"