How do I list the dependencies for a package using pip?
2 Answers
In current pip (version 1.3.1) you can see the dependencies of an installed package by using:
pip show <package>

- 53,225
- 8
- 158
- 177

- 1,994
- 3
- 13
- 11
-
102Note that this only works for installed packages. – JonnyJD Oct 15 '13 at 17:08
-
cd env ; bin/python -c 'import pip ; D = { d.key: d for d in pip.get_installed_distributions() } ; F = lambda xs: sum([ F(x) if isinstance(x, list) else [x] for x in xs ], []) ; R = lambda k: [k] + F([ R(r.key) for r in D[k].requires() ]) ; print " ".join(R("mypkg") if "mypkg" in D else [])' – j0057 Jan 06 '14 at 16:20
-
2Also see http://stackoverflow.com/a/30450999/207981 – maltem-za Nov 10 '16 at 08:18
-
10how to look for a package before installing it? – Bersan Jan 19 '22 at 13:07
-
1pip download
--verbose [for uninstalled packages] – MorLavender Sep 25 '22 at 11:59
Note that this answer from 2012 is out of date. First, the workaround, which the answer already said you probably shouldn't do in 2012, now you can't do it. If you want a similar workaround, you could use pip download
, but it's even less likely to be what you want. Especially since pip show
has been improved. Fortunately, the question has been marked as a dup of a later question, so there's no reason to read this answer except for historical purposes.
You can't, at least not directly.
You can import the pip module in your own code and download the requirements file and then iterate through it. Or, from the command line, you can pip install --no-install --verbose
.
But really, unless this is something you need to automate, it's probably easier to just go to http://pypi.python.org/ and search for the package there instead of using pip.

- 354,177
- 51
- 601
- 671
-
26
-
7On my pip version (10.0.0) there is no such option like `--no-install`. – avalanchy Apr 16 '18 at 06:19
-
2@avalanchy Why are you trying to do something that a 6-year-old answer tells you that you probably shouldn't do, when the question has been marked as a dup of a newer answer that tells you the right way? – abarnert Apr 16 '18 at 17:31
-
1@abarnert My stupid brain somehow thought OP was referring to another off-screen answer as being out-of-date (instead of this one), and I ended up trying this as well. *facepalm* – jkmartindale May 22 '18 at 14:56
-
-