gpt4 book ai didi

python-3.x - pip3 安装了一个违反需求说明符的依赖版本

转载 作者:行者123 更新时间:2023-12-04 01:09:05 24 4
gpt4 key购买 nike

我的 requirements.txt 中有以下两个依赖项:

$ pip3 install elasticsearch==7.0.0 requests==2.21.0
Collecting elasticsearch==7.0.0
Using cached https://files.pythonhosted.org/packages/a8/27/d3a9ecd9f8f972d99da98672d4766b9f62ef64c323c40bb5e2557e538ea3/elasticsearch-7.0.0-py2.py3-none-any.whl
Collecting requests==2.21.0
Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Collecting urllib3>=1.21.1 (from elasticsearch==7.0.0)
Using cached https://files.pythonhosted.org/packages/39/ec/d93dfc69617a028915df914339ef66936ea976ef24fa62940fd86ba0326e/urllib3-1.25.2-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25.2 which is incompatible.
Installing collected packages: urllib3, elasticsearch, certifi, chardet, idna, requests
Successfully installed certifi-2019.3.9 chardet-3.0.4 elasticsearch-7.0.0 idna-2.8 requests-2.21.0 urllib3-1.25.2

我想了解上面输出中出现的这个警告:

requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25.2 which is incompatible.

为什么pip安装urllib3 1.25.2 ?这似乎没有意义。所需的依赖项是:

  • elasticsearch==7.0.0需要 urllib3>=1.21.1 ( source )
  • requests==2.21.0需要 urllib3>=1.21.1,<1.25 ( source )

这两个依赖项可以通过安装 urllib3 1.24.3 轻松满足。 .为什么 pip3然后安装urllib3 1.25.2 ?根据可用需求决定正确的版本不是它的职责之一吗?

这是 pip3 中的错误或者这是否按设计运行?

最佳答案

2020 年 11 月 10 日更新

安装 beta 版 pip,它会为你正确解决依赖关系。

或者安装最新的稳定版并运行pip install --use-feature=2020-resolver .

原始答案

现在,pip doesn’t have true dependency resolution ,而是简单地使用它为项目找到的第一个规范。

您可以添加 constraints.txt 文件,urllib3==1.24.3 然后调用:

$ pip install -r requirements.txt -c contraints.txt

这样就可以了。更新需求时,记得同时更新约束条件。

或者,您可以使用 Python dependency managers 之一:

参见 Requirements FilesConstraints Files pip 用户指南和 Managing Application Dependencies 中的部分教程。

关于python-3.x - pip3 安装了一个违反需求说明符的依赖版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56096643/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com