简体   繁体   English

Pip 在安装期间显示 package 安装的依赖原理

[英]Pip show dependency rationale for package installation during install

When I am trying to install some packages with pip, sometimes some dependency fails to install, and I need to sort out why.当我尝试使用 pip 安装一些软件包时,有时某些依赖项无法安装,我需要找出原因。 A fundamental question is "why did I need to install package X at all?", but I cannot find any way to answer this from the pip install output, even with -vvv .一个基本问题是“为什么我需要安装 package X?”,但我无法从pip install -vvv中找到任何方法来回答这个问题, Pip tells me what it is installing, but it doesn't say why it is doing it. Pip 告诉我它正在安装什么,但它没有说明它为什么这样做。

There are various tools to introspect dependency trees of packages, eg pipdeptree , especially when they are already installed, but these don't help me when the installation has failed.有各种工具可以检查包的依赖树,例如pipdeptree ,尤其是当它们已经安装时,但是当安装失败时这些对我没有帮助。 And it seems that internally pip must already have solved these dependencies and know why it has chosen to install a particular package.而且内部 pip 似乎已经解决了这些依赖关系,并且知道为什么它选择安装特定的 package。 So how can I get it to share this information with me at install time?那么我怎样才能让它在安装时与我分享这些信息呢?

Edit: It already shows this information when telling you what dependencies are already satisfied, eg编辑:在告诉您已经满足哪些依赖项时,它已经显示了此信息,例如

Requirement already satisfied: pillow>=6.2.0 in /data2/users/bfarmer/envs/bfarmer_dev_py  39/lib/python3.9/site-packages (from matplotlib>=1.3.1->stf-modelling) (8.0.1)
Requirement already satisfied: certifi>=2020.06.20 in /data2/users/bfarmer/envs/bfarmer_  dev_py39/lib/python3.9/site-packages (from matplotlib>=1.3.1->stf-modelling) (2020.12.5)

(at least I assume that it is what it is telling me at the end of those lines). (至少我认为这是它在这些行末尾告诉我的内容)。 But when I need this information the most, ie when something goes wrong, I get nothing:但是当我最需要这些信息时,即出现问题时,我什么也得不到:

Collecting PIL
  Downloading http://ehp.bom.gov.au/ehprepo/pypi/simple/pil/PIL-1.1.7.tar.gz (506 kB)
     |████████████████████████████████| 506 kB 8.1 MB/s
    ERROR: Command errored out with exit status 1:
    ...
    <traceback etc. follows>

In this example I am left wondering why the heck some package wanted PIL when pillow is already there.在这个例子中,我想知道为什么有些 package 想要 PIL,而枕头已经在那里了。 PIL is basically dead, so I need to update whatever package has a dependency on PIL to use pillow instead. PIL 基本上已经死了,所以我需要更新任何 package 对 PIL 的依赖来使用枕头。 But I have no idea what package that might be, and cannot figure out any way to find out.但我不知道 package 可能是什么,并且无法找出任何方法来找出答案。 This seems like basic information, there must surely be a way to get it.这似乎是基本信息,肯定有办法得到它。

It kind of seems like no, pip cannot do this.好像不行,pip 不能做到这一点。 I found this issue about it here:我在这里发现了这个问题:

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

It sounds like they are working on it, but nothing exists currently.听起来他们正在研究它,但目前什么都不存在。 I am still interested in workaround/third party solutions though, or advice from other developers about what they typically do in this situation.不过,我仍然对解决方法/第三方解决方案感兴趣,或者其他开发人员关于他们在这种情况下通常会做什么的建议。 It kind of seems like I just have to manually trawl through all the dependencies of my dependencies, which just seems stupid.似乎我只需要手动搜索我的依赖项的所有依赖项,这看起来很愚蠢。 Maybe I can hack something in to the pip source...也许我可以破解 pip 源代码...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM