如何使用 PIP 查看依赖于某个包的所有包? [英] How can I see all packages that depend on a certain package with PIP?

查看:114
本文介绍了如何使用 PIP 查看依赖于某个包的所有包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看依赖于带有 PIP 的某个包的包列表.也就是说,给定django,我想看看django-cmsdjango-filer,因为我已经安装了这些包并且它们都有django 作为依赖.

I would like to see a list of packages that depend on a certain package with PIP. That is, given django, I would like to see django-cms, django-filer, because I have these packages installed and they all have django as dependency.

推荐答案

更新(2021):

pip 版本 10 开始,您可以:

Since pip version 10 you can do:

pkg=httplib2
pip show $pkg | grep ^Required-by

或用于 bash

pkg=httplib2
grep ^Required-by <(pip show $pkg)

所以你可以创建一个别名,如:

so you could create an alias like:

alias pyreq='pip show $pkg | grep ^Required-by'

并通过以下方式查询:

pkg=httplib2 pyreq

应该给出(对于 ubuntu):

which should give (for ubuntu):

Required-by: lazr.restfulclient, launchpadlib


原文:


Original:

很简单:

pip show <insert_package_name_here>| grep ^Requires

或者反过来:(对不起,我弄错了!)

Or the other way around: (sorry i got it wrong!)

for NAME in $(pip freeze | cut -d= -f1); do REQ=$(pip show $NAME| grep Requires); if [[ "$REQ" =~ "$REQUIRES" ]]; then echo $REQ;echo "Package: $NAME"; echo "---" ; fi;  done

在此之前将您的搜索字符串设置为:

before that set your search-string with:

REQUIRES=django

基本上你必须遍历整个列表并查询每一个.这可能需要一些时间.

essentially you have to go through the whole list and query for every single one. That may take some time.

它也只适用于已安装的包,我没有看到 pip 提供对未安装包的依赖.

这篇关于如何使用 PIP 查看依赖于某个包的所有包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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