How can I see all packages that depend on a certain package with PIP?
Since version 10, pip show
also includes a "Required-by" entry. So just
pip show <package_name>
is enough nowadays. Or possibly
pip show <package_name> | grep ^Required-by
if you want to get just that single line for a script or whatever.
I know there's already an accepted answer here, but really, it seems to me that what you want is to use pipdeptree:
pip install pipdeptree
pipdeptree --help
pipdeptree -r -p django
Update (2021):
Since pip
version 10 you can do:
pkg=httplib2
pip show $pkg | grep ^Required-by
or for bash
pkg=httplib2
grep ^Required-by <(pip show $pkg)
so you could create an alias like:
alias pyreq='pip show $pkg | grep ^Required-by'
and querying by:
pkg=httplib2 pyreq
which should give (for ubuntu):
Required-by: lazr.restfulclient, launchpadlib
Original:
Quite straightforward:
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.
Edit: Also it does only work on installed packages, I don't see pip providing dependencies on not installed packages.