102

How do I list the dependencies for a package using pip?

0

2 Answers 2

152

In current pip (version 1.3.1) you can see the dependencies of an installed package by using:

pip show <package>
5
  • 101
    Note that this only works for installed packages.
    – JonnyJD
    Oct 15, 2013 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 6, 2014 at 16:20
  • 2
    Also see stackoverflow.com/a/30450999/207981
    – maltem-za
    Nov 10, 2016 at 8:18
  • 10
    how to look for a package before installing it?
    – Bersan
    Jan 19, 2022 at 13:07
  • 1
    pip download <package> --verbose [for uninstalled packages] Sep 25, 2022 at 11:59
12

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.

6
  • 26
    On my pip version (1.5.4) the --no-install flag is deprecated.
    – Jian
    May 9, 2014 at 6:25
  • 7
    On my pip version (10.0.0) there is no such option like --no-install.
    – avalanchy
    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?
    – abarnert
    Apr 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
  • does not work anymore
    – Atif Ali
    Aug 15, 2022 at 7:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.