显示与pip的反向依赖关系?

编程入门 行业动态 更新时间:2024-10-28 02:30:29
本文介绍了显示与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的反向依赖关系?

本文发布于:2023-07-04 17:06:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关系   pip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!