我想查看依赖于带有 PIP 的某个包的包列表.也就是说,给定django,我想看看django-cms、django-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 查看依赖于某个包的所有包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
python:不同包下同名的两个模块和类python: Two modules and classes with the same name under different packages(python:不同包下同名的两个模块和类)
配置 Python 以使用站点包的其他位置Configuring Python to use additional locations for site-packages(配置 Python 以使用站点包的其他位置)
如何在不重复导入顶级名称的情况下构造python包How to structure python packages without repeating top level name for import(如何在不重复导入顶级名称的情况下构造python包)
在 OpenShift 上安装 python 包Install python packages on OpenShift(在 OpenShift 上安装 python 包)
如何刷新 sys.path?How to refresh sys.path?(如何刷新 sys.path?)
分发带有已编译动态共享库的 Python 包Distribute a Python package with a compiled dynamic shared library(分发带有已编译动态共享库的 Python 包)