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.

- 17,038
- 20
- 114
- 194
-
PIP installed: `pip 1.4.1` – linkyndy Dec 17 '13 at 14:21
5 Answers
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.

- 11,227
- 5
- 36
- 54
-
2You got it wrong. I would like to see what _required_ the given package, not what _requires_ the given package. – linkyndy Dec 17 '13 at 14:17
-
@DonQuestion But this only shows it for the currently installed packages right? Is there anyway to search through the whole PyPi list? – Tijme Jul 18 '17 at 16:14
-
2This does not work, but returns an error: Usage: pip show [options]
... no such option: ------------------ – mikkokotila May 11 '18 at 07:38 -
1leaving this for my sad self while skipping warning to run this on a deprecated python version `for NAME in $(python -W ignore -m pip freeze | cut -d= -f1); do REQ=$(python -W ignore -m pip show $NAME| grep Requires); if [[ "$REQ" =~ "$REQUIRES" ]]; then echo $REQ;echo "Package: $NAME"; echo "---" ; fi; done` – theannouncer Feb 04 '21 at 01:42
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

- 3,363
- 1
- 18
- 21
-
Should be accepted answer! Reason: 1. works on the python ecosystem, more comfortable for a python developer than the answer by @Don_Question. 2. Very simplistic commands 3. Mentions CLI Tool specifically designed to solve OP's question – Hamza Zubair Jun 11 '20 at 06:22
-
You have a point here! But pipdeptree is much younger then the question. And if you need a one shot solution you really don't want to install a package, when you can do it in "one" line of shellscript! ;-) – Don Question Feb 09 '21 at 02:32
-
3Just wanted to note explicitly that this (good) answer shares a limitation with accepted answer: it won't tell you about packages that aren't installed. (I came here looking for that additional functionality to troubleshoot a package that won't install on my M1 Mac.) – Paul Bissex Sep 21 '21 at 16:09
-
@PaulBissex were you able find any workaround for your case. Facing similar issue – jefe23984 Nov 17 '22 at 04:21
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.

- 61
- 2
- 4
This one, for pip older than 1.3.1 will list all packages and it's dependencies, you can parse its output with any scripting language, for Requires ... django
inclusions:
pip freeze | cut -f 1 -d'=' | xargs -L1 pip show
For example, following snippet:
import os
import re
package = 'numpy'
regex = re.compile('.*{}($|,).*'.format(package))
def chunks(l, n): return [l[i:i+n] for i in range(0, len(l), n)]
cmd = "pip freeze | cut -f 1 -d'=' | xargs -L1 pip show"
packages = os.popen(cmd).read()
pkg_infos = chunks(packages.splitlines(), 5)
print '\n'.join(x[1][6:] for x in filter(lambda x: regex.match(x[-1]), pkg_infos))
outputs pandas
on my system.

- 46,136
- 12
- 94
- 102
-
I was looking for something more straight-forward, something that requires only some shell commands. – linkyndy Dec 17 '13 at 14:20
-
One liner based on requirements.txt. In this example I'm looking for funcsigs
reverse dependency, and found mock. Just change funcsigs
by something else.
cat requirements.txt | grep -v git | sed 's/==.*//' | xargs -I % echo 'pip show % 2>/dev/null | grep Requires | grep -q funcsigs && echo %' | sh

- 5,687
- 1
- 41
- 53