Package: pip-licenses
Dump the software license list of Python packages installed with pip.Table of ContentsDescriptionInstallationUsageCommand-Line OptionsCommon optionsOption: pythonOption: fromOption: orderOption: formatMarkdownreSTConfluenceHTMLJSONJSON LicenseFinderCSVPlain VerticalOption: summaryOption: output-fileOption: ignore-packagesOption: packagesFormat optionsOption: with-systemOption: with-authorsOption: with-maintainersOption: with-urlsOption: with-descriptionOption: no-versionOption: with-license-fileOption: filter-stringsOption: filter-code-pageVerify optionsOption: fail-onOption: allow-onlyMore InformationDockerfileAbout UnicodeEncodeErrorLicenseDependenciesUninstallationContributingDescriptionpip-licensesis a CLI tool for checking the software license of
installed Python packages with pip.Implemented with the idea inspired bycomposer licensescommand in
Composer (a.k.a PHP package management tool).https://getcomposer.org/doc/03-cli.md#licensesInstallationInstall it via PyPI usingpipcommand.# Install or Upgrade to newest available version$pipinstall-Upip-licenses# If upgrading from pip-licenses 3.x, remove PTable$pipuninstall-yPTableNote 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$pipinstall'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.$pipinstall'pip-licenses<2.0'UsageExecute the command with your venv (or virtualenv) environment.# Install packages in your venv environment(venv)$pipinstallDjangopip-licenses# Check the licenses with your venv environment(venv)$pip-licensesNameVersionLicenseDjango2.0.2BSDpytz2017.3MITCommand-Line OptionsCommon optionsOption: pythonBy default, this tools finds the packages from the environment
pip-licenses is launched from, by searching in current python’ssys.pathfolders. 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’ssys.path,
free of pip-licenses dependencies.(venv)$pip-licenses--with-system|greppippip22.3.1MITLicensepip-licenses4.1.0MITLicense(venv)$pip-licenses--python=</path/to/other/env>/bin/python--with-system|greppippip23.0.1MITLicenseOption: fromBy default, this tool finds the license fromTrove
Classifiersor 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#LicenseFor example, even if you check with thepip showcommand, the
license is displayed asUNKNOWN.(venv)$pipshowsetuptoolsName:setuptoolsVersion:38.5.0Summary:Easilydownload,build,install,upgrade,anduninstallPythonpackagesHome-page:https://github.com/pypa/setuptoolsAuthor:PythonPackagingAuthorityAuthor-email:distutils-sig@python.orgLicense:UNKNOWNThe mixed mode (--from=mixed) of this tool works well and looks for
licenses.(venv)$pip-licenses--from=mixed--with-system|grepsetuptoolssetuptools38.5.0MITLicenseIn 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 thewith-authorsandwith-urlsoptions and contact the software
author.Themkeyword is prepared as alias ofmeta.Theckeyword is prepared as alias ofclassifier.Themixkeyword is prepared as alias ofmixed.Default behavior in this toolOption: orderBy default, it is ordered by package name.If you give arguments to the--orderoption, you can output in other
sorted order.(venv)$pip-licenses--order=licenseOption: formatBy default, it is output to theplainformat.MarkdownWhen executed with the--format=markdownoption, you can output list
in markdown format. Themmdkeyword is prepared as alias ofmarkdown.(venv)$pip-licenses--format=markdown|Name|Version|License||--------|---------|---------||Django|2.0.2|BSD||pytz|2017.3|MIT|When inserted in a markdown document, it is rendered as follows:NameVersionLicenseDjango2.0.2BSDpytz2017.3MITreSTWhen executed with the--format=rstoption, you can output list in
“Grid
tables”
of reStructuredText format. Therrestkeyword is prepared as
alias ofrst.(venv)$pip-licenses--format=rst+--------+---------+---------+|Name|Version|License|+--------+---------+---------+|Django|2.0.2|BSD|+--------+---------+---------+|pytz|2017.3|MIT|+--------+---------+---------+ConfluenceWhen executed with the--format=confluenceoption, you can output
list inConfluence (or JIRA) Wiki
markupformat. Theckeyword is prepared as alias ofconfluence.(venv)$pip-licenses--format=confluence|Name|Version|License||Django|2.0.2|BSD||pytz|2017.3|MIT|HTMLWhen executed with the--format=htmloption, you can output list in
HTML table format. Thehkeyword is prepared as alias ofhtml.(venv)$pip-licenses--format=html<table><tr><th>Name</th><th>Version</th><th>License</th></tr><tr><td>Django</td><td>2.0.2</td><td>BSD</td></tr><tr><td>pytz</td><td>2017.3</td><td>MIT</td></tr></table>JSONWhen executed with the--format=jsonoption, you can output list in
JSON format easily allowing post-processing. Thejkeyword is
prepared as alias ofjson.[{"Author":"Django Software Foundation","License":"BSD","Name":"Django","URL":"https://www.djangoproject.com/","Version":"2.0.2"},{"Author":"Stuart Bishop","License":"MIT","Name":"pytz","URL":"http://pythonhosted.org/pytz","Version":"2017.3"}]JSON LicenseFinderWhen executed with the--format=json-license-finderoption, you can
output list in JSON format that is identical toLicenseFinder. Thejlfkeyword is prepared as alias ofjlf. This makes pip-licenses
a drop-in replacement for LicenseFinder.[{"licenses":["BSD"],"name":"Django","version":"2.0.2"},{"licenses":["MIT"],"name":"pytz","version":"2017.3"}]CSVWhen executed with the--format=csvoption, 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","2.0.2","BSD""pytz","2017.3","MIT"Plain VerticalWhen executed with the--format=plain-verticaloption, 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-pathpytest5.3.4MITlicenseTheMITLicense(MIT)Copyright(c)2004-2020HolgerKrekelandothersPermissionisherebygranted,freeofcharge,toanypersonobtainingacopyofthissoftwareandassociateddocumentationfiles(the"Software"),todealintheSoftwarewithoutrestriction,includingwithoutlimitationtherightstouse,copy,modify,merge,publish,distribute,sublicense,and/orsellcopiesoftheSoftware,andtopermitpersonstowhomtheSoftwareisfurnishedtodoso,subjecttothefollowingconditions:TheabovecopyrightnoticeandthispermissionnoticeshallbeincludedinallcopiesorsubstantialportionsoftheSoftware.THESOFTWAREISPROVIDED"AS IS",WITHOUTWARRANTYOFANYKIND,EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTIONOFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE.Option: summaryWhen executed with the--summaryoption, you can output a summary of
each license.(venv)$pip-licenses--summary--from=classifier--with-systemCountLicense2BSDLicense4MITLicenseNote:When using this option, only--order=countor--order=licensehas an effect for the--orderoption. And using--with-authorsand--with-urlswill be ignored.Option: output-fileWhen executed with the--output-fileoption, write the result to the
path specified by the argument.(venv) $ pip-licenses --format=rst --output-file=/tmp/output.rst
created path: /tmp/output.rstOption: ignore-packagesWhen executed with the--ignore-packagesoption, ignore the package
specified by argument from list output.(venv)$pip-licenses--ignore-packagesdjangoNameVersionLicensepytz2017.3MITPackage names of arguments can be separated by spaces.(venv)$pip-licenses--with-system--ignore-packagesdjangopippip-licensesNameVersionLicenseprettytable3.5.0BSDLicensepytz2017.3MITsetuptools38.5.0UNKNOWNwcwidth0.2.5MITLicensePackages can also be specified with a version, only ignoring that
specific version.(venv)$pip-licenses--with-system--ignore-packagesdjangopytz:2017.3NameVersionLicenseprettytable3.5.0BSDLicensesetuptools38.5.0UNKNOWNwcwidth0.2.5MITLicenseOption: packagesWhen executed with thepackagesoption, look at the package
specified by argument from list output.(venv)$pip-licenses--packagesdjangoNameVersionLicenseDjango2.0.2BSDPackage names of arguments can be separated by spaces.(venv)$pip-licenses--with-system--packagesprettytablepytzNameVersionLicenseprettytable3.5.0BSDLicensepytz2017.3MITFormat optionsOption: with-systemBy default, system packages such aspipandsetuptoolsare
ignored.Andpip-licensesand the implicit dependencyprettytableandwcwidthwill also be ignored.If you want to output all including system package, use the--with-systemoption.(venv)$pip-licenses--with-systemNameVersionLicenseDjango2.0.2BSDpip9.0.1MITpip-licenses1.0.0MITLicenseprettytable3.5.0BSDLicensepytz2017.3MITsetuptools38.5.0UNKNOWNwcwidth0.2.5MITLicenseOption: with-authorsWhen executed with the--with-authorsoption, output with author of
the package.(venv)$pip-licenses--with-authorsNameVersionLicenseAuthorDjango2.0.2BSDDjangoSoftwareFoundationpytz2017.3MITStuartBishopOption: with-maintainersWhen executed with the--with-maintainersoption, 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#144Option: with-urlsFor packages without Metadata, the license is output asUNKNOWN. To
get more package information, use the--with-urlsoption.(venv)$pip-licenses--with-urlsNameVersionLicenseURLDjango2.0.2BSDhttps://www.djangoproject.com/pytz2017.3MIThttp://pythonhosted.org/pytzOption: with-descriptionWhen executed with the--with-descriptionoption, output with short
description of the package.(venv)$pip-licenses--with-descriptionNameVersionLicenseDescriptionDjango2.0.2BSDAhigh-levelPythonWebframeworkthatencouragesrapiddevelopmentandclean,pragmaticdesign.pytz2017.3MITWorldtimezonedefinitions,modernandhistoricalOption: no-versionWhen executed with the--no-versionoption, output without the
version number.(venv)$pip-licenses--no-versionNameLicenseDjangoBSDpytzMITOption: with-license-fileWhen executed with the--with-license-fileoption, 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 fileNOTICEdistributed under Apache
License etc., specify the--with-notice-fileoption additionally.Note:If you want to keep the license file path secret, specify--no-license-pathoption together.Option: filter-stringsSome 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).Option: filter-code-pageIf the input strings are filtered (see--filter-strings), you can
specify the applied code page (defaultlatin-1). A list of all
available code pages can be foundcodecs module
document.Verify optionsOption: fail-onFail (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  23.0.1   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"Option: allow-onlyFail (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  23.0.1   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 $?
1More InformationOther, please make sure to execute the--helpoption.DockerfileYou can check the package license used by your app in the isolated
Docker environment.# Clone this repository to local$gitclonehttps://github.com/raimon49/pip-licenses.git$cdpip-licenses# Create your app's requirements.txt file
# Other ways, pip freeze > docker/requirements.txt$echo"Flask">docker/requirements.txt# Build docker image$dockerbuild.-tmyapp-licenses# Check the package license in container$dockerrun--rmmyapp-licensesNameVersionLicenseClick7.0BSDLicenseFlask1.0.2BSDLicenseJinja22.10BSDLicenseMarkupSafe1.1.1BSDLicenseWerkzeug0.15.2BSDLicenseitsdangerous1.1.0BSDLicense# Check with options$dockerrun--rmmyapp-licenses--summaryCountLicense4BSD2BSD-3-Clause# When you need help$dockerrun--rmmyapp-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/Dockerfileindex bfc4edc..175e968 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,4 +1,4 @@-FROM python:3.11-slim-bullseye+FROM python:3.11-bullseyeAbout UnicodeEncodeErrorIf aUnicodeEncodeErroroccurs, check your environment variablesLANGandLC_TYPE. Additionally, you can setPYTHONIOENCODINGto override the encoding used forstdout.Often occurs in isolated environments such as Docker and tox.See useful reports:#35#45LicenseMIT
LicenseDependenciesprettytableby Luke
Maurits and maintainer of fork version Jazzband team under the
BSD-3-Clause LicenseNote:This package implicitly requireswcwidth.pip-licenseshas been implemented in the policy to minimize the
dependence on external package.UninstallationUninstall package and dependent package withpipcommand.$pipuninstallpip-licensesprettytablewcwidthContributingSeecontribution
guidelines.CHANGELOG4.3.4Maintain to pass test with wcwidth>=0.2.104.3.3Always terminate--allow-onlyand--fail-onmessages with a
newlineAlways terminate files created with--output-filewith a newline4.3.2Better handling extracting URLs fromProject-URL4.3.1Fix to treat package names as normalized as inPEP
503with--packagesand--ignore-packagesoption4.3.0Implement new option--no-version4.2.0Implement new option--with-maintainersImplement new option--pythonAllow version spec in--ignore-packagesparametersWhen theAuthorfield isUNKNOWN, the output is automatically
completed fromAuthor-emailWhen thehome-pagefield isUNKNOWN, the output is
automatically completed fromProject-URL4.1.0Support case-insensitive license name matching around--fail-onand--allow-onlyparameters4.0.3Escape unicode output (to e.g.&#123;) in the html output4.0.2Add type annotations and code formatter4.0.1Fix “pip-licenses” is missing in output ofpip-licenses--with-systemoption4.0.0Support for Python 3.11Dropped support Python 3.7Migrate Docker base image from Alpine to Debian 11-slimBreaking changesDoes not work with PTable and depends on prettytableDepend on importlib_metadata rather than pip3.5.5Search for path defined inPEP
639with--with-license-fileoptionDropped support Python 3.63.5.4Skip directories when detecting license files3.5.3Support pip 21.3 or later3.5.2Ignore spaces around--fail-onand--allow-onlyparameters3.5.1Fix the order in which multiple licenses are output3.5.0Handle multiple licenses better with options--fail-onand--allow-onlySmall change in output method for multiple licenses, change the
separator from comma to semicolonUp to 3.4.0:Python Software Foundation License, MIT License3.5.0 or later:Python Software Foundation License; MIT License3.4.0Implement new option--packages3.3.1Fix license summary refer to--fromoption3.3.0Improves the readability of the help command3.2.0Implement new option--from=allChange license notation underSPDX license
identifierstyle3.1.0Implement new option for use in continuous integration--fail-on--allow-only3.0.0Dropped support Python 3.5Clarified support for Python 3.9Migrate package metadata tosetup.cfgBreaking changesChange default behavior to--from=mixed2.3.0Implement new option for manage unicode characters--filter-strings--filter-code-page2.2.1Fixed the file that is selected when multiple matches are made withLICENSE*with run--with-license-file2.2.0Implement new option--with-notice-fileAdded to find British style file nameLICENCEwith run--with-license-file2.1.1Suppress errors when opening license files2.1.0Implement new option--format=plain-verticalSupport for outputting license file namedCOPYING *2.0.1Better license file open handling in Python 32.0.0Dropped support Python 2.7Breaking changesRemoved migration path to obsolete options--from-classifier--format-markdown--format-rst--format-confluence--format-html--format-jsonImplement new option--no-license-path1.18.0Supports compatibility to work with either PTable or prettytable1.17.0Implement new option--output-fileClarified support for Python 3.81.16.1Add a help text for--format=json-license-finderoption1.16.0Implement new option--format=json-license-finder1.15.2Read license file works well with Windows1.15.1Skip parsing of license file for packages specified with--ignore-packagesoption1.15.0Implement new option--format=csv1.14.0Implement new option--from=mixedas a mixed mode1.13.0Implement new option--from=meta,from=classifierDropped support Python 3.41.12.1Fix bugChange warning output to standard error1.12.0Supports execution within Docker containerWarning of deprecated optionsFix bugIgnoreOSI Approvedstring with multiple licenses1.11.0Implement new option--with-license-file1.10.0Implement new option--with-description1.9.0Implement new option--summary1.8.0Implement new option--format-jsonDropped support Python 3.31.7.1Fix bugSupport pip 10.x1.7.0Implement new option--format-confluence1.6.1Fix bugSupport display multiple license with--from-classifieroptionImprove documentAdd section of ‘Uninstallation’ in README1.6.0Implement new option--format-html1.5.0Implement new option--format-rst1.4.0Implement new option--format-markdownInclude LICENSE file in distribution package1.3.0Implement new option--ignore-packages1.2.0Implement new option--from-classifier1.1.0Improve documentAdd ToC to README documentAdd a information of dependencies1.0.0First stable release version0.2.0Implement new option--orderDefault behavior is--order=name0.1.0First implementation versionSupport options--with-system--with-authors--with-urls