pip-licenses is a command-line interface (CLI) tool designed to efficiently list the software licenses of Python packages installed via pip. It is actively maintained with regular updates, aligning with the release cadence of `pip` itself. The current version is 5.5.5.
pip install pip-licensesNo compatibility data collected yet for this library.
The primary usage of `pip-licenses` is through its command-line interface. After installation, simply running `pip-licenses` will display a table of all non-system Python packages and their associated licenses in your current environment. Common options include `--with-system` to include system packages, `--fail-on` to exit with an error if a specific license is detected, `--format` for different output types (e.g., json, html, markdown), and `--summary` to get a count of packages per license.
Ensure your Python environment is 3.9 or newer, or install a compatible older version of `pip-licenses` (e.g., `pip install 'pip-licenses<4.0'` for Python 3.7).
After upgrading `pip-licenses`, run `pip uninstall -y PTable`.
Update any parsing logic to expect semicolons as separators for multiple licenses.
To include system packages in the output, use the `--with-system` option: `pip-licenses --with-system`.
For programmatic access, use the `pip-licenses-lib` package (e.g., `pip install pip-licenses-lib`) and import `piplicenses_lib` functions.
Review and update any scripts that parse the `--from=all` output to account for the new `License-Expression` field.
Ensure pip-licenses is installed in your active Python environment using `pip install -U pip-licenses` and that your environment's scripts directory (e.g., `venv/bin` or `venv/Scripts`) is included in your system's PATH. You may need to reactivate your virtual environment or open a new terminal.
Upgrade pip-licenses to the latest available version using `pip install -U pip-licenses`. This issue was resolved in newer versions of the library, often with release candidates for immediate fixes.
Run `pip-licenses --from=mixed` to instruct pip-licenses to first check Trove Classifiers and then fallback to package Metadata. If the license is still 'UNKNOWN', you might need to manually inspect the package's metadata or repository for the license information.
Set your terminal or system's `LANG` and `LC_ALL` environment variables to a UTF-8 locale (e.g., `export LANG=en_US.UTF-8` and `export LC_ALL=en_US.UTF-8` on Linux/macOS) before executing the pip-licenses command.
Install a compatible version of pip-licenses for your Python environment. For Python 3.7, use `pip install 'pip-licenses<4.0'`. For Python 2.7, use `pip install 'pip-licenses<2.0'`.