Dump the software license list of Python packages installed with pip.
Important
The next version will bring breaking changes!
You may notice documentation has begun to describe the version 6-series already. A living
document to assist with migrating to the v6-series is now available, while some of the
more custodial work wraps up for the release of the v6.0.0 release in December 2026.
Table of Contents
pip-licenses is a CLI tool for checking the software license of installed Python packages with pip.
Implemented with the idea inspired by composer licenses command in Composer (a.k.a PHP package management tool).
https://getcomposer.org/doc/03-cli.md#licenses
Install it via PyPI using pip command.
# Install or Upgrade to newest available version
$ pip install -U pip-licensesLegacy Python Hints
Note for Python 3.8 users: pip-licenses 5.x discontinued support for Python 3.8. If you want to use it with Python 3.8 anyway, install pip-licenses 4.5.x.
# Using old version for the Python 3.8 environment
$ pip install 'pip-licenses<5.0'
# If upgrading from pip-licenses 3.x, remove PTable
$ pip uninstall -y PTableNote for Python 3.7 users: pip-licenses 4.x discontinued support earlier than the Python 3.7 EOL schedule. If you want to use it with Python 3.7, install pip-licenses 3.x.
# Using old version for the Python 3.7 environment
$ pip install 'pip-licenses<4.0'Note: If you are still using Python 2.7, install version less than 2.0. No new features will be provided for version 1.x.
$ pip install 'pip-licenses<2.0'Simply invoke the command to scan the current environment:
pip-licenses
demo$ pip-licenses
Name Version License
cffi 2.1.1 MIT-0
packaging 26.3 Apache-2.0 OR BSD-2-Clause
pycparser 3.0 BSD-3-Clause
Tip
Alternatively execute the command within virtualenv (or the legacy venv) environment.
| Option | Argument(s) | Default | Description |
|---|---|---|---|
--python |
path | current interpreter | Python executable whose sys.path is searched for packages. |
--from |
meta, classifier, mixed, all |
mixed |
Source used to look up license information. |
--order |
name, license, author, url, count |
name |
Column used to sort the output. |
--format |
plain, plain-vertical, markdown, rst, confluence, html, json, json-license-finder, csv |
plain |
Output format of the report. |
--summary |
None (flag takes no values) | off | Output a count summary per license instead of a package list. |
--output-file |
path | stdout | Write the result to the given file path. |
--ignore-packages |
package names | none | Exclude the listed packages from the output. |
--packages |
package names | all | Limit the output to the listed packages only. |
By default, this tools finds the packages from the environment pip-licenses is launched from, by searching in current python's sys.path folders. In the case you want to search for packages in an other environment (e.g. if you want to run pip-licenses from its own isolated environment), you can specify a path to a python executable. The packages will be searched for in the given python's sys.path, free of pip-licenses dependencies.
demo$ pip-licenses --with-system | grep pip
pip 26.2.1 MIT
pip-licenses 6.0.0b11 MIT
(venv) $ pip-licenses --python=</path/to/other/env>/bin/python --with-system | grep pip
pip 26.2 MITBy default, this tool finds the license from Trove Classifiers or package Metadata. Some Python packages declare their license only in Trove Classifiers.
(See also): Set license to MIT in setup.py by alisianoi ・ Pull Request #1058 ・ pypa/setuptools, PEP 314#License
For example, even if you check with the pip show command, the license is displayed as UNKNOWN or simply empty.
demo$ # this is what pip shows:
demo$ pip show aniso8601
Name: aniso8601
Version: 10.0.1
Summary: A library for parsing ISO 8601 strings.
Home-page: https://codeberg.org/nielsenb-jf/aniso8601
Author: Brandon Nielsen
Author-email: nielsenb@jetfuse.net
License:
Requires:
Required-by:
demo$ # this is what pip-licenses shows:
demo$ pip-licenses -p aniso8601 --from=mixed --with-system
Name Version License
aniso8601 10.0.1 BSD License
The mixed mode (--from=mixed) of this tool works well and looks for licenses.
In mixed mode, it first tries to look for licenses in the Trove Classifiers. When not found in the Trove Classifiers, the license declared in Metadata is displayed.
If you want to look only in metadata, use --from=meta. If you want to look only in Trove Classifiers, use --from=classifier.
To list license information from both metadata and classifier, use --from=all.
Note: If neither can find license information, please check with the with-authors and with-urls options and contact the software author.
- The
mkeyword is prepared as alias ofmeta. - The
ckeyword is prepared as alias ofclassifier. - The
mixkeyword is prepared as alias ofmixed.- Default behavior in this tool
By default, it is ordered by package name.
If you give arguments to the --order option, you can output in other sorted order.
(venv) $ pip-licenses --order=licenseBy default, it is output to the plain format.
When executed with the --format=markdown option, you can output list in markdown format. The m md keyword is prepared as alias of markdown.
(venv) $ pip-licenses --format=markdown
| Name | Version | License |
|--------|---------|--------------|
| Django | 6.0.6 | BSD-3-Clause |
| pytz | 2026.2 | MIT License |When inserted in a markdown document, it is rendered as follows:
| Name | Version | License |
|---|---|---|
| Django | 6.0.6 | BSD-3-Clause |
| pytz | 2026.2 | MIT License |
When executed with the --format=rst option, you can output list in "Grid tables" of reStructuredText format. The r rest keyword is prepared as alias of rst.
(venv) $ pip-licenses --format=rst
+--------+---------+--------------+
| Name | Version | License |
+--------+---------+--------------+
| Django | 6.0.6 | BSD-3-Clause |
+--------+---------+--------------+
| pytz | 2026.2 | MIT License |
+--------+---------+--------------+When executed with the --format=confluence option, you can output list in Confluence (or JIRA) Wiki markup format. The c keyword is prepared as alias of confluence.
(venv) $ pip-licenses --format=confluence
| Name | Version | License |
| Django | 6.0.6 | BSD-3-Clause |
| pytz | 2026.2 | MIT License |When executed with the --format=html option, you can output list in HTML table format. The h keyword is prepared as alias of html.
(venv) $ pip-licenses --format=html
<table>
<thead>
<tr>
<th>Name</th>
<th>Version</th>
<th>License</th>
</tr>
</thead>
<tbody>
<tr>
<td>Django</td>
<td>6.0.6</td>
<td>BSD-3-Clause</td>
</tr>
<tr>
<td>pytz</td>
<td>2026.2</td>
<td>MIT License</td>
</tr>
</tbody>
</table>When executed with the --format=json option, you can output list in JSON format easily allowing post-processing. The j keyword is prepared as alias of json.
[
{
"Author": "Django Software Foundation <foundation@djangoproject.com>",
"License": "BSD-3-Clause",
"Name": "Django",
"URL": "https://www.djangoproject.com/",
"Version": "6.0.6"
},
{
"Author": "Stuart Bishop",
"License": "MIT License",
"Name": "pytz",
"URL": "http://pythonhosted.org/pytz",
"Version": "2026.2"
}
]When executed with the --format=json-license-finder option, you can output list in JSON format that is identical to LicenseFinder. The jlf keyword is prepared as alias of jlf.
This makes pip-licenses a drop-in replacement for LicenseFinder.
[
{
"licenses": ["BSD-3-Clause"],
"name": "Django",
"version": "6.0.6"
},
{
"licenses": ["MIT License"],
"name": "pytz",
"version": "2026.2"
}
]
When executed with the --format=csv option, you can output list in quoted CSV format. Useful when you want to copy/paste the output to an Excel sheet.
(venv) $ pip-licenses --format=csv
"Name","Version","License"
"Django","6.0.6","BSD-3-Clause"
"pytz","2026.2","MIT License"When executed with the --format=plain-vertical option, you can output a simple plain vertical output that is similar to Angular CLI's
--extractLicenses flag. This format minimizes rightward drift.
(venv) $ pip-licenses --format=plain-vertical --with-license-file --no-license-path
pytest
9.1.1
MIT
The MIT License (MIT)
Copyright (c) 2004 Holger Krekel and others
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.When executed with the --summary option, you can output a summary of each license.
(venv) $ pip-licenses --summary --from=classifier --with-system
Count License
2 BSD-3-Clause
4 MIT
1 MIT LicenseNote: When using this option, only --order=count or --order=license has an effect for the --order option. And using --with-authors and --with-urls will be ignored.
When executed with the --output-file option, write the result to the path specified by the argument.
(venv) $ pip-licenses --format=rst --output-file=/tmp/output.rst
created path: /tmp/output.rst
When executed with the --ignore-packages option, ignore the package specified by argument from list output.
(venv) $ pip-licenses --ignore-packages django
Name Version License
pytz 2026.2 MIT LicensePackage names of arguments can be separated by spaces.
(venv) $ pip-licenses --with-system --ignore-packages django pip pip-licenses
Name Version License
prettytable 3.18.0 BSD-3-Clause
pytz 2026.2 MIT License
setuptools 83.0.0 MIT
wcwidth 0.8.2 MITPackages can also be specified with a version, only ignoring that specific version.
(venv) $ pip-licenses --with-system --ignore-packages django pytz:2026.2
Name Version License
prettytable 3.18.0 BSD-3-Clause
setuptools 83.0.0 MIT
wcwidth 0.8.2 MITWhen executed with the packages option, look at the package specified by argument from list output.
(venv) $ pip-licenses --packages django
Name Version License
Django 6.0.6 BSD-3-ClausePackage names of arguments can be separated by spaces.
(venv) $ pip-licenses --with-system --packages prettytable pytz
Name Version License
prettytable 3.18.0 BSD-3-Clause
pytz 2026.2 MIT LicenseBy default, system packages such as pip and setuptools are ignored.
And pip-licenses and the implicit dependency prettytable and wcwidth will also be ignored.
If you want to output all including system package, use the --with-system option.
(venv) $ pip-licenses --with-system
Name Version License
Django 6.0.6 BSD-3-Clause
pip 26.1.2 MIT
pip-licenses 5.5.5 MIT
prettytable 3.18.0 BSD-3-Clause
pytz 2026.2 MIT License
setuptools 83.0.0 MIT
wcwidth 0.8.2 MITWhen executed with the --with-authors option, output with author of the package.
(venv) $ pip-licenses --with-authors
Name Version License Author
Django 6.0.6 BSD-3-Clause Django Software Foundation <foundation@djangoproject.com>
pytz 2026.2 MIT License Stuart BishopWhen executed with the --with-maintainers option, output with maintainer of the package.
Note: This option is available for users who want information about the maintainer as well as the author. See #144
For packages without Metadata, the license is output as UNKNOWN. To get more package information, use the --with-urls option.
(venv) $ pip-licenses --with-urls
Name Version License URL
Django 6.0.6 BSD-3-Clause https://www.djangoproject.com/
pytz 2026.2 MIT License http://pythonhosted.org/pytzWhen executed with the --with-description option, output with short description of the package.
(venv) $ pip-licenses --with-description
Name Version License Description
Django 6.0.6 BSD-3-Clause A high-level Python web framework that encourages rapid development and clean, pragmatic design.
pytz 2026.2 MIT License World timezone definitions, modern and historicalWhen executed with the --no-version option, output without the version number.
(venv) $ pip-licenses --no-version
Name License
Django BSD-3-Clause
pytz MIT LicenseWhen executed with the --with-license-file option, output the location of the package's license file on disk and the full contents of that file. Due to the length of these fields, this option is best paired with --format=json.
If you also want to output the file NOTICE distributed under Apache License etc., specify the --with-notice-file option additionally.
Note: If you want to keep the license file path secret, specify --no-license-path option together.
Note: When using --with-license-file with structured formats like CSV, Markdown, reST, or Confluence, the multi-line license file contents can break the formatting. For documentation workflows (like Sphinx), consider using separate commands:
# Generate clean RST table for documentation
$ pip-licenses --from=mixed --format=rst --output-file summary.rst
# Generate license file contents in plain-vertical format for inclusion
$ pip-licenses --from=mixed --format=plain-vertical --with-license-file --no-license-path --output-file with_license.txtThe RST file can be rendered nicely in Sphinx, while the plain-vertical format preserves the license file contents as monospace text.
Some package data contains Unicode characters which might cause problems for certain output formats (in particular ReST tables). If this filter is enabled, all characters which cannot be encoded with a given code page (see --filter-code-page) will be removed from any input strings (e.g. package name, description).
If the input strings are filtered (see --filter-strings), you can specify the applied code page (default latin-1). A list of all available code pages can be found codecs module document.
Fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list. The license name matching is case-insensitive.
If --from=all, the option will apply to the metadata license field.
(venv) $ pip-licenses --fail-on="MIT License;BSD License"Note: Packages with multiple licenses will fail if at least one license is included in the fail-on list. For example:
# keyring library has 2 licenses
$ pip-licenses --package keyring
Name Version License
keyring 25.7.0 MIT License; Python Software Foundation License
# If just "Python Software Foundation License" is specified, it will fail.
$ pip-licenses --package keyring --fail-on="Python Software Foundation License;"
$ echo $?
1
# Matching is case-insensitive. Following check will fail:
$ pip-licenses --fail-on="mit license"
Warn (write to stderr, without failing) on every occurrence of the licenses of the
semicolon-separated list. The license name matching is case-insensitive. This keeps --allow-only
runs green while making obligations that need follow-up visible, for example licences that require
attribution in the documentation.
(venv) $ pip-licenses --allow-only="MIT License;Python Software Foundation License" --warn-on="Python Software Foundation License"Note: Unlike --fail-on and --allow-only, the run does not stop at the first occurrence:
one warning line is printed per package, and the exit code stays 0.
Fail (exit with code 1) if none of the package licenses are in the semicolon-separated list. The license name matching is case-insensitive.
If --from=all, the option will apply to the metadata license field.
(venv) $ pip-licenses --allow-only="MIT License;BSD License"Note: Packages with multiple licenses will only be allowed if at least one license is included in the allow-only list. For example:
# keyring library has 2 licenses
$ pip-licenses --package keyring
Name Version License
keyring 25.7.0 MIT License; Python Software Foundation License
# One or both licenses must be specified (order and case does not matter). Following checks will pass:
$ pip-licenses --package keyring --allow-only="MIT License"
$ pip-licenses --package keyring --allow-only="mit License"
$ pip-licenses --package keyring --allow-only="BSD License;MIT License"
$ pip-licenses --package keyring --allow-only="Python Software Foundation License"
$ pip-licenses --package keyring --allow-only="Python Software Foundation License;MIT License"
# If none of the license in the allow list match, the check will fail.
$ pip-licenses --package keyring --allow-only="BSD License"
$ echo $?
1
If set, enables partial (substring) matching for --fail-on, --warn-on or --allow-only. Default is unset (False).
Usage:
(venv) $ pip-licenses --partial-match --allow-only="MIT License;BSD License"
(venv) $ pip-licenses --partial-match --fail-on="MIT License;BSD License"
Note: Semantics are the same as with --fail-on or --allow-only. This only enables substring matching.
# keyring library has 2 licenses
$ pip-licenses --package keyring
Name Version License
keyring 25.7.0 MIT License; Python Software Foundation License
# One or both licenses must be specified (order and case does not matter). Following checks will pass:
$ pip-licenses --package keyring --allow-only="MIT License"
$ pip-licenses --package keyring --allow-only="mit License"
$ pip-licenses --package keyring --allow-only="BSD License;MIT License"
$ pip-licenses --package keyring --allow-only="Python Software Foundation License"
$ pip-licenses --package keyring --allow-only="Python Software Foundation License;MIT License"
# These won't pass, as they're not a full match against one of the licenses
$ pip-licenses --package keyring --allow-only="MIT"
$ echo $?
1
$ pip-licenses --package keyring --allow-only="mit"
$ echo $?
1
# with --partial-match, they pass
$ pip-licenses --package keyring --partial-match --allow-only="MIT"
$ echo $?
0
$ pip-licenses --package keyring --partial-match --allow-only="mit"
$ echo $?
0
All command-line options for pip-licenses can be configured using the pyproject.toml file under the [tool.pip-licenses] section.
The pyproject.toml file is searched in the directory where the pip-licenses script is executed.
Command-line options specified during execution will override the corresponding options in pyproject.toml.
Example pyproject.toml configuration:
[tool.pip-licenses]
from = "classifier"
ignore-packages = [
"scipy"
]
fail-on = "MIT;"If you run pip-licenses without any command-line options, all options will be taken from the pyproject.toml file.
For instance, if you run pip-licenses --from=mixed, the from option will be overridden to mixed, while all other options will be sourced from pyproject.toml.
Other, please make sure to execute the --help option.
You can check the package license used by your app in the isolated Docker environment.
# Clone this repository to local
$ git clone https://github.com/raimon49/pip-licenses.git
$ cd pip-licenses
# Create your app's requirements.txt file
# Other ways, pip freeze > docker/requirements.txt
$ echo "Flask" > docker/requirements.txt
# Build docker image
$ docker build . -t myapp-licenses
# Check the package license in container
$ docker run --rm myapp-licenses
Name Version License
Click 7.0 BSD License
Flask 1.0.2 BSD License
Jinja2 2.10 BSD License
MarkupSafe 1.1.1 BSD License
Werkzeug 0.15.2 BSD License
itsdangerous 1.1.0 BSD License
# Check with options
$ docker run --rm myapp-licenses --summary
Count License
4 BSD
2 BSD-3-Clause
# When you need help
$ docker run --rm myapp-licenses --helpNote: This Docker image can not check package licenses with C and C++ Extensions. It only works with pure Python package dependencies.
If you want to resolve build environment issues, try using not slim image and more.
diff --git a/Dockerfile b/Dockerfile
index bfc4edc..81f9264 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.14-slim-trixie
+FROM python:3.14-trixieIf a UnicodeEncodeError occurs, check your environment variables LANG and LC_TYPE. Additionally, you can set PYTHONIOENCODING to override the encoding used for stdout.
Often occurs in isolated environments such as Docker and tox.
See useful reports:
-
prettytable by Luke Maurits and maintainer of fork version Jazzband team under the BSD-3-Clause License
- Note: This package implicitly requires wcwidth.
-
tomli by Taneli Hukkinen under the MIT License
pip-licenses has been implemented in the policy to minimize the dependence on external package.
Uninstall package and dependent package with pip command.
$ pip uninstall pip-licenses prettytable wcwidth