2

I'm struggling to install gym suddenly in Google Colab.

The error looks like this:

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting gym[accept-rom-license,atari]==0.21.0
  Using cached gym-0.21.0.tar.gz (1.5 MB)
  error: subprocess-exited-with-error
  
  × python setup.py egg_info 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.
  Preparing metadata (setup.py) ... error
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. 

I've upgraded pip and setuptools, and installed ez_setup, but nothing worked.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

1 Answers1

1

TL;DR Downgrade your setuptools==65.5.0 and wheel<0.40.0

!pip install setuptools==65.5.0 "wheel<0.40.0"

Details:

The issue here seems to be related to wheel (0.40.0+) and setuptools (66.0.0+) that is now reporting a version string in gym==0.21.0's setup file as no longer valid. The following traceback comes from building wheel for Gym as reported in Github #3202 for gym

...
wheel.vendored.packaging.requirements.InvalidRequirement: Expected end or semicolon (after version specifier)
opencv-python>=3.

which refers to opencv-python>=3. string in the setup.py. It would appear that newer versions of wheel is raising errors here.

One workaround that you can find in Github issue #3211 is to downgrade the versions of setuptools and wheel, as in:

!pip install setuptools==65.5.0 "wheel<0.40.0"

After restarting the kernel, you should be able to run:

!pip install gym==0.21.0
knight
  • 300
  • 2
  • 7