Is there a way to list pip dependencies/requirements? Is there a way to list pip dependencies/requirements? python python

Is there a way to list pip dependencies/requirements?


The accepted answer is no longer relevant for more current versions of pip and does not give an immediate answer without perusing multiple comments so I am providing an updated answer.

This was tested with pip versions 8.1.2, 9.0.1, 10.0.1, and 18.1.

To get the output without cluttering your current directory on Linux use

pip download [package] -d /tmp --no-binary :all: -v

-d tells pip the directory that download should put files in.

Better, just use this script with the argument being the package name to get only the dependencies as output:

#!/bin/shPACKAGE=$1pip download $PACKAGE -d /tmp --no-binary :all:-v 2>&1 \| grep Collecting \| cut -d' ' -f2 \| grep -Ev "$PACKAGE(~|=|\!|>|<|$)"

Also available here.


Check out my project johnnydep!

Installation:

pip install johnnydep

Usage example:

$ johnnydep requestsname                       summary-------------------------  ----------------------------------------------------------------------requests                   Python HTTP for Humans.├── certifi>=2017.4.17     Python package for providing Mozilla's CA Bundle.├── chardet<3.1.0,>=3.0.2  Universal encoding detector for Python 2 and 3├── idna<2.7,>=2.5         Internationalized Domain Names in Applications (IDNA)└── urllib3<1.23,>=1.21.1  HTTP library with thread-safe connection pooling, file post, and more.

A more complex tree:

$ johnnydep ipython name                              summary--------------------------------  -----------------------------------------------------------------------------ipython                           IPython: Productive Interactive Computing├── appnope                       Disable App Nap on OS X 10.9├── decorator                     Better living through Python with decorators├── jedi>=0.10                    An autocompletion tool for Python that can be used for text editors.│   └── parso==0.1.1              A Python Parser├── pexpect                       Pexpect allows easy control of interactive console applications.│   └── ptyprocess>=0.5           Run a subprocess in a pseudo terminal├── pickleshare                   Tiny 'shelve'-like database with concurrency support├── prompt-toolkit<2.0.0,>=1.0.4  Library for building powerful interactive command lines in Python│   ├── six>=1.9.0                Python 2 and 3 compatibility utilities│   └── wcwidth                   Measures number of Terminal column cells of wide-character codes├── pygments                      Pygments is a syntax highlighting package written in Python.├── setuptools>=18.5              Easily download, build, install, upgrade, and uninstall Python packages├── simplegeneric>0.8             Simple generic functions (similar to Python's own len(), pickle.dump(), etc.)└── traitlets>=4.2                Traitlets Python config system    ├── decorator                 Better living through Python with decorators    ├── ipython-genutils          Vestigial utilities from IPython    └── six                       Python 2 and 3 compatibility utilities


If and only if the package is install, you can use pip show <package>. Look for the Requires: filed at the end of the output. Clearly, this breaks your requirement but might be useful nonetheless.

For example:

$ pip --versionpip 7.1.0 [...]$ pip show pytest---Metadata-Version: 2.0Name: pytestVersion: 2.7.2Summary: pytest: simple powerful testing with PythonHome-page: http://pytest.orgAuthor: Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and othersAuthor-email: holger at merlinux.euLicense: MIT licenseLocation: /home/usr/.tox/develop/lib/python2.7/site-packagesRequires: py