如何使用 PIP 查看依赖于某个包的所有包?

How can I see all packages that depend on a certain package with PIP?(如何使用 PIP 查看依赖于某个包的所有包?)
本文介绍了如何使用 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 查看依赖于某个包的所有包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)