为什么“pip installgym”失败并出现“python setup.py Egg_info 未成功运行”错误?

2023-12-22

我突然很难在 Google Colab 中安装gym。

错误看起来像这样:

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. 

我已经升级了 pip 和 setuptools,并安装了 ez_setup,但没有任何效果。


TL;DR降级您的setuptools==65.5.0 and wheel<0.40.0

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

Details:

这里的问题似乎与wheel(0.40.0+) 和setuptools(66.0.0+) 现在报告版本字符串gym==0.21.0的安装文件不再有效。以下回溯来自 Gym 的构建轮,如报告中所述Github #3202 健身房 https://github.com/openai/gym/issues/3202

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

这是指opencv-python>=3.中的字符串setup.py https://github.com/openai/gym/blob/v0.21.0/setup.py#L20。看来较新版本的wheel在这里引发错误。

您可以在其中找到一种解决方法Github 问题 #3211 https://github.com/openai/gym/issues/3211就是降级setuptools和wheel的版本,如下:

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

重新启动内核后,您应该能够运行:

!pip install gym==0.21.0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么“pip installgym”失败并出现“python setup.py Egg_info 未成功运行”错误? 的相关文章

随机推荐