openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.87k stars 8.62k forks source link

[Bug Report] Version 0.21 could not be installed. #3176

Open dydgus5120 opened 1 year ago

dydgus5120 commented 1 year ago

Describe the bug

I got the following error while trying to install stable baselines 3 Checking the setup.py of stable baselines 3, it was supposed to install gym version 0.21, so when I tried to install gym version 0.21 separately, the same error came out.

how do i solve it?

Code example

Collecting gym==0.21
  Using cached gym-0.21.0.tar.gz (1.5 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info 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: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

System Info I installed with pip install gym==0.21 from docker on ubuntu 22.04 distro with wsl2 on windows 11. docker base image is also ubuntu 22.04

Python version is 3.10.6.

Checklist

dydgus5120 commented 1 year ago

It appears to be incompatible with your version of setuptools. It was not installed in the 67 version, but it was installed in the 66 version.

pseudo-rnd-thoughts commented 1 year ago

What is the maximum version of setuptools allowed? As v0.21 is 2 years old, there are no plan to make a new release

duenez commented 1 year ago

From setuptools: https://github.com/pypa/setuptools/issues/3801

pip3 install setuptools==65.5.0

stefanbschneider commented 1 year ago

I have the same issue and it's odd because we have been using gym 0.21 for a long time without problems. Did something change with the release or is it because there's a new setuptools version that is responsible?

Btw, I also can't access the release notes for 0.21: https://github.com/openai/gym/releases/tag/0.21.0 Is that on purpose?

pseudo-rnd-thoughts commented 1 year ago

It looks like setuptools made a change that causes an error to be raised that previously did not therefore, setuptools either need to revert the change or users must use a prior version of setuptools than 65.5.0

You forgot a v in the version - https://github.com/openai/gym/releases/tag/v0.21.0

dafmdev commented 1 year ago

I have this problem too, which version of GYM supports a higher version of setuptools?

stefanbschneider commented 1 year ago

It looks like setuptools made a change that causes an error to be raised that previously did not therefore, setuptools either need to revert the change or users must use a prior version of setuptools than 65.5.0

Seems like this was an intentional change of setuptools that will not be fixed: https://github.com/pypa/setuptools/issues/3772#issuecomment-1384342813 I'm not sure how to fix it on Gym side, though; didn't check all the details.

viraaj-jayaram commented 1 year ago

I had the same issue and then even with downgrading setuptools I could not fix the problem because it kept getting killed. However, downgrading the setup tools and then bypassing the cache with pip install stable-baselines3[extra] --no-cache-dir finally worked for me.

pseudo-rnd-thoughts commented 1 year ago

Some authors have noted that you might need to downgrade wheel<0.40.0 (https://github.com/openai/gym/issues/3211)

xmatthias commented 1 year ago

it's become a real problem - as you'll ALSO need to downgrade pip to <23.1 (iirc) - as that has a packaging update that dumps support for the syntax error in the requirements file.

We've since been able to update to the alpha/beta version of sb3, which drops gym as dependency in favor of gymnasium, which basically fixed all install problems in this regard.

araffin commented 1 year ago

So, for all people having the issue, please take a look at https://github.com/Stable-Baselines-Team/stable-baselines3-contrib/issues/184#issuecomment-1556859789

in short, if you need to use gym 0.21 (and SB3 v1.x), you need to downgrade both setuptools and pip

pip install setuptools==65.5.0 pip==21  # gym 0.21 installation is broken with more recent versions

otherwise, the solution is to upgrade to gymnasium and SB3 v2.x (in beta currently):

pip install "sb3_contrib>=2.0.0a9" # SB3 contrib also installs SB3
deep-over commented 6 months ago

I have successfully resolved the installation issue with gym-0.21.0 by manually downloading and modifying the source code.

Download the gym-0.21.0.tar.gz file from PyPI. tar -xvf gym-0.21.0.tar.gz. Modify the setup.py file. The error was located in the line containing opencv-python>=3.. After making the necessary correction, I completed the installation process.

Yildirimm commented 5 months ago

From setuptools: pypa/setuptools#3801

pip3 install setuptools==65.5.0

for the ones who have still some problems, check here: https://github.com/openai/gym/issues/3211