且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

pip 无法正确解决子/孙依赖项

更新时间:2022-05-23 22:37:35

我相信这是目前正在解决的一个众所周知的问题.一周前的消息: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: