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

when i try to install gym[box2d] i get following error: i tried: pip install gym[box2d]. on anaconda prompt i installed swig and gym[box2d] but i code in python3.9 env and it still not working.(my text editor is pycharm) gym is already 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: 


Solution 1:[1]

according to Anaconda, you should use the following command

conda install -c conda-forge gym-box2d

but you can still just install gym and from gym.envs import box2d

Solution 2:[2]

I think you are using windows for using openai gym which is not officially supported. gym installation for windows is not stable. Linux and mac are officially supported. I recommended this video Installing OpenAI Gym (gym[all]) on Linux, Windows and Mac for installing in Linux. you can use wsl2 in windows which i tried and worked.

Also this doc gym 0.7.4 helped me to set up the display in using wsl2(alias linux server according to the docs ?).

Individual installation like box2d did not work for me. Try to install all gym envs as said in the video(takes a lot of space ? but no other option)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Thrinay0403