本文介绍了显示与pip的反向依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以用pip显示反向依赖关系?
Is it possible to show the reverse dependencies with pip?
我想知道哪个软件包需要软件包foo.以及此软件包需要哪个版本的foo.
I want to know which package needs package foo. And which version of foo is needed by this package.
推荐答案对于使用pip的python API已安装的软件包,这是可能的. pip.get_installed_distributions功能,可以为您提供当前安装的所有第三方软件包的列表.
This is possible for already installed packages using pip's python API. There is the pip.get_installed_distributions function, which can give you a list of all third party packages currently installed.
# rev_deps.py import pip import sys def find_reverse_deps(package_name): return [ pkg.project_name for pkg in pip.get_installed_distributions() if package_name in {req.project_name for req in pkg.requires()} ] if __name__ == '__main__': print find_reverse_deps(sys.argv[1])此脚本将输出需要指定软件包的软件包列表:
This script will output the list of packages, that require a specified one:
$python rev_deps.py requests更多推荐
显示与pip的反向依赖关系?
发布评论