更新python包后出现“InvalidRequirement:无效的要求,解析错误”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35625488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:41:59  来源:igfitidea点击:

"InvalidRequirement: Invalid requirement, parse error" error after updating a python package

pythonpipsetuptools

提问by ThiefMaster

After updating a package (IPython in my case) using pip install -U ipythonrunning any Python script that uses entry points fails with this error:

使用pip install -U ipython运行任何使用入口点的 Python 脚本更新包(在我的情况下为 IPython)后失败并显示以下错误:

Traceback (most recent call last):
  File "/home/adrian/dev/indico/env/bin/indico", line 5, in <module>
    from pkg_resources import load_entry_point
  ...
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
    requirement_string[e.loc:e.loc + 8], requirement_string))
pkg_resources._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'< 2.0'"

Nothing else changed, I did not update any other libraries.

没有其他变化,我没有更新任何其他库。

采纳答案by ThiefMaster

This is caused by an issue in setuptools==20.2.1which is pulled in by IPython (setuptools>..), so a pip install -Uupdated it.

这是setuptools==20.2.1由 IPython ( setuptools>..)引入的问题引起的,因此对其进行了pip install -U更新。

Until a fixed version is released or the broken version is pulled from PyPI there is a simple workaround (but note that it will break again if something updates setuptools):

在发布固定版本或从 PyPI 中提取损坏的版本之前,有一个简单的解决方法(但请注意,如果更新 setuptools 它将再次损坏):

  • pip install -U pip
  • pip uninstall setuptools
  • pip install 'setuptools<20.2'
  • pip install -U pip
  • pip uninstall setuptools
  • pip install 'setuptools<20.2'

The pipupdate is needed since older versions of pipwill not work without setuptoolsbeing installed

pip因为旧版本的更新,需要pip将无法正常工作没有setuptools安装



See these IRC logs and BitBucket issue for details:

有关详细信息,请参阅这些 IRC 日志和 BitBucket 问题:

回答by juanpaolo

Try downgrading your pip to 8.1.1:

尝试将您的 pip 降级为8.1.1

pip install pip==8.1.1

That solved it for me.

那为我解决了。