pip 无法正确解决子/孙依赖项 [英] pip not properly resolving child/grandchild dependencies

查看:59
本文介绍了pip 无法正确解决子/孙依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样工作的模块依赖树(→ 表示依赖):

I have a dependency tree of modules that works like this (→ indicating a dependency):

a → b, c
b → ruamel.yaml >= 0.16.5
c → ruamel.yaml < 0.16.6, >=0.12.4

我很清楚 ruamel.yaml 0.16.5 将正确解析这两个依赖项.但是,当我 pip install a 时,我得到以下日志:

It's very clear to me that ruamel.yaml 0.16.5 will resolve both of these dependencies correctly. However, when I pip install a, I get the following logs:

Collecting ruamel.yaml>=0.16.5
  Downloading ruamel.yaml-0.16.10-py2.py3-none-any.whl (111 kB)

然后:

ERROR: <package c> 0.4.0 has requirement ruamel.yaml<0.16.6,>=0.12.4, but you'll have ruamel-yaml 0.16.10 which is incompatible.

所以 pip 在选择安装哪些包时完全忽略了孙子依赖.但它意识到它最终搞砸了.为什么 pip 没有在这里选择正确的包.有没有办法帮助它更好地工作?

So pip has completely ignored the grandchild dependencies when choosing which packages to install. But it realises that it has messed up at the end. Why is pip not choosing the correct package here. Is there a way to help it work better?

推荐答案

我相信这是目前正在解决的一个众所周知的问题.一周前的消息:http://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html

I believe this is a well known problem that is currently being worked on. Message from one week ago: http://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html

与此同时,可以采取一些措施来尝试缓解此类问题:

In the meantime there are some measures that can be taken to try and mitigate this kind of issues:

  • 恢复依赖项的顺序(在您的示例中,a 可以在 b 之前列出 c)
  • 使用额外的requirements.txtconstraints.txt 文件
  • 根据实际需要,另一种工具可以提供帮助(我相信 poetrypipenv,很可能其他人也可能有更好的依赖解析器,但它们不是 pip) 的一对一替代品
  • Revert the order of the dependencies (in your example a could list c before b)
  • Use an additional requirements.txt or constraints.txt file
  • Depending on the actual needs, an alternative tool could help (I believe poetry, pipenv, and most likely others as well might have better dependency resolvers, but they are not a one-to-one replacement for pip)

今天似乎已经可以测试 pip 的未来依赖解析器:

It appears to be already possible to test pip's future dependency resolver today:

在某种程度上,似乎也可以通过 pip check 命令在当前版本或 pip 中测试此依赖项解析器.

In a way it also seems to be possible to somewhat test this dependency resolver in current releases or pip via the pip check command.

有关该主题的更多参考资料:

Some more references on the topic:

这篇关于pip 无法正确解决子/孙依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆