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>
-
101
-
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 [])'– j0057Jan 6, 2014 at 16:20
-
2
-
10
-
1
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.
-
26
-
7On my pip version (10.0.0) there is no such option like
--no-install. Apr 16, 2018 at 6: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?– abarnertApr 16, 2018 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 May 22, 2018 at 14:56
-