pip 要求说明符:逗号的作用

pip requirement specifiers: role of the comma

我正在尝试安装特定版本的 django-cms,因此执行 pip install django-cms==3.0.5。这给了我错误 No matching distribution found for django-mptt==0.5.2,==0.6,==0.6.1 (from django-cms==3.0.5)。事实上,在 github 上,setup.py 文件指定了要求 django-mptt==0.5.2,==0.6,==0.6.1

specification 表示逗号作为逻辑 'and' 运算符,但显然没有版本可以同时为 0.5.2、0.6 和 0.6.1,因此要求不是匹配。只需通过 pip install django-mptt==0.5.2 安装其中一个版本就可以正常工作,但关于 django-cms==3.0.5.

仍然存在相同的错误

任何人都可以阐明这一点吗?

这是 django-cms 版本 3.0.5 中的错误。您可以在此处查看问题:https://github.com/divio/django-cms/issues/3704.

如果您需要继续使用 3.0 版本,可以尝试安装 3.0.16 版本。如果你真的需要 3.0.5 版,你可以安装 pip==1.5.6,并且 django-cms 应该仍然可以正确安装。

编辑 从 pip 版本 6.0 开始,单个包的多个 == 版本说明符不再有效。其中一位开发人员评论 Github:

This is the new expected behavior from PEP 440.

The old behavior of setuptools was confusing and didn't do what most people expected it to do. PEP 440 simplified it by changing the , to a logical AND statement.

https://github.com/pypa/pip/issues/2258