pipdeptree
pipdeptree is a command line utility for displaying the python packages installed in an environment in form of a dependency tree. Since pip freeze shows all dependencies as a flat list, finding out which are the top level packages and which packages do they depend on requires some effort. This utility tries to solve this problem.
Installation
$ pip install pipdeptree
Usage and examples
To give you a brief idea, here is the output of pipdeptree compared with pip freeze:
$ pip freeze
Flask==0.10.1
Flask-Script==0.6.6
Jinja2==2.7.2
Mako==0.9.1
MarkupSafe==0.18
SQLAlchemy==0.9.1
Werkzeug==0.9.4
alembic==0.6.2
argparse==1.2.1
itsdangerous==0.23
psycopg2==2.5.2
redis==2.9.1
slugify==0.0.1
wsgiref==0.1.2
And now see what pipdeptree outputs,
$ pipdeptree
wsgiref==0.1.2
argparse==1.2.1
psycopg2==2.5.2
Flask-Script==0.6.6
- Flask [installed: 0.10.1]
- Werkzeug [required: >=0.7, installed: 0.9.4]
- Jinja2 [required: >=2.4, installed: 2.7.2]
- markupsafe [installed: 0.18]
- itsdangerous [required: >=0.21, installed: 0.23]
alembic==0.6.2
- SQLAlchemy [required: >=0.7.3, installed: 0.9.1]
- Mako [installed: 0.9.1]
- MarkupSafe [required: >=0.9.2, installed: 0.18]
slugify==0.0.1
redis==2.9.1
If you wish to track only the top level packages in your requirements.txt file, you could use grep as follows,
$ pipdeptree | grep -P '^[\w0-9\-=.]+'
wsgiref==0.1.2
argparse==1.2.1
psycopg2==2.5.2
Flask-Script==0.6.6
alembic==0.6.2
slugify==0.0.1
redis==2.9.1
$ pipdeptree | grep -P '^[\w0-9\-=.]+' > requirements.txt
Usage
$ pipdeptree -h
usage: pipdeptree [-h] [-a] [-l]
Dependency tree of the installed python packages
optional arguments:
-h, --help show this help message and exit
-a, --all list all deps at top level
-l, --local-only list only the installations local to the current
virtualenv, if in a virtualenv
Known Issues
One thing you might have noticed already is that flask is shown as a dependency of flask-script, which although correct, sounds a bit odd. flask-script is being used here because we are using flask and not the other way around. Same with sqlalchemy and alembic. I haven’t yet thought about a possible solution to this! (May be if libs that are “extensions” could be distinguished from the ones that are “dependencies”. Suggestions are welcome.)
License
MIT (See LICENSE)
Metadata
Release files for pipdeptree 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pipdeptree-0.1.tar.gz | 3.5 kB | Without provenance | Details |
Release files / pipdeptree-0.1.tar.gz
| Download URL | pipdeptree-0.1.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b601c872cbe77b13ed1a39aba82604cb4c0569ec71d003589424acfd4ce1931a
|
|
BLAKE2b-256 checksum How to use checksums |
35101bea372702af625474adb1ecb663cc8b7c91b480e1e08e064e9c338a33d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pipdeptree 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.