[英]I have not changed requirements in my Divio project, so why does the build fail with a dependency conflict?
The last time I deployed the project, the build worked perfectly.我上次部署该项目时,构建工作完美。
In the meantime I have changed nothing that would affect the pip requirements, yet I get an error when building:同时,我没有更改任何会影响 pip 要求的内容,但是在构建时出现错误:
Could not find a version that matches Django<1.10,<1.10.999,<1.11,
<1.12,<1.9.999,<2,<2.0,==1.9.13,>1.3,>=1.11,>=1.3,>=1.4,>=1.4.10,
>=1.4.2,>=1.5,>=1.6,>=1.7,>=1.8
I get the same error when building the project locally with docker-compose build web
.使用docker-compose build web
在本地构建项目时,我遇到了同样的错误。
What could be the problem?可能是什么问题呢?
The problem here is that although you may not have modified any requirements, the dependencies of a project can sometimes change on their own.这里的问题是,尽管您可能没有修改任何需求,但项目的依赖项有时会自行更改。
You may even have pinned all of your own requirements (which is generally a good idea) but that still won't help if one of them itself has an unpinned dependency.您甚至可能已经固定了您自己的所有需求(这通常是一个好主意),但是如果其中一个本身具有未固定的依赖项,那仍然无济于事。
Anywhere an unpinned dependency exists, you can run into this.任何存在未固定依赖项的地方,您都可能遇到这种情况。
Here's an example.这是一个例子。 Suppose your requirements.in
contains super-django==1.2.4
.假设您的requirements.in
包含super-django==1.2.4
。 That's better than simply specifying super-django
, as you won't be taken by surprised if a new, incompatible version of the Super Django package is released.这比简单地指定super-django
更好,因为如果发布了新的、不兼容的 Super Django 包版本,您不会感到惊讶。
But suppose that in turn Super Django 1.2.4, in its requirements, lists:但是假设 Super Django 1.2.4 在其要求中列出:
Django==1.11
django-super-admin
If a new version of Django Super Admin is released, that requires say Django>=2.0
, your next build will fail because of the mutually exclusive requirements.如果发布了 Django Super Admin 的新版本,这需要说Django>=2.0
,您的下一个构建将由于相互排斥的要求而失败。
To track down the culprit when you run into such a failure, you need to examine the build logs.要在遇到此类故障时追查罪魁祸首,您需要检查构建日志。 You'll see there something like:你会在那里看到类似的东西:
Could not find a version that matches Django==1.11,>=2.0 [etc].
So now you know to look back through the logs to find what is wanting to install Django>=2.0
, and you'll find:所以现在你知道回顾日志以找到想要安装Django>=2.0
,你会发现:
adding Django>=2.0
from django-super-admin==1.7.0
So now you know that it's django-super-admin==1.7.0
that is the key.所以现在你知道django-super-admin==1.7.0
是关键。 Since you can't trust super-django
to pin the correct version of django-super-admin
, you'll have to do it yourself, by adding django-super-admin<1.7.0
to the requirements.in
of your project.由于您不能相信super-django
会固定正确版本的django-super-admin
,因此您必须自己完成,方法是将django-super-admin<1.7.0
到项目的requirements.in
中。
There's more information about this at How to identify and resolve a dependency conflict .在如何识别和解决依赖冲突中有更多关于此的信息。
You can also Pin all of your project's Python dependencies to ensure this never happens again with any other dependency, though you sacrifice some flexibility for the guarantee.您还可以固定项目的所有 Python 依赖项,以确保任何其他依赖项不会再次发生这种情况,尽管您会为保证牺牲一些灵活性。
Note: I am a member of the Divio team.注意:我是 Divio 团队的成员。 This question is one that we see quite regularly via our support channels.这个问题是我们经常通过我们的支持渠道看到的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.