{"library":"pip-licenses","title":"pip-licenses","description":"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.","language":"python","status":"active","last_verified":"Sat Apr 11","install":{"commands":["pip install pip-licenses"],"cli":{"name":"pip-licenses","version":"pip-licenses 5.5.5"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\n\n# Install pip-licenses and a sample package (if not already installed)\n# os.system('pip install Django pip-licenses')\n\n# Basic usage: list all installed package licenses\nprint(\"\\n--- Basic License List ---\")\nos.system('pip-licenses')\n\n# Include system packages like pip and setuptools\nprint(\"\\n--- With System Packages ---\")\nos.system('pip-licenses --with-system')\n\n# Fail if a specific license (e.g., AGPL) is found\nprint(\"\\n--- Fail on AGPL (example, might exit with error) ---\")\n# For demonstration, we use a common permissive license (MIT) to show failure.\n# In a real scenario, you'd check for restrictive licenses like AGPL.\n# This command will exit with a non-zero code if MIT is found.\n# os.system('pip-licenses --fail-on \"MIT License\" --partial-match')\n\n# Output in JSON format\nprint(\"\\n--- Output in JSON Format (first 1000 chars) ---\")\njson_output = os.popen('pip-licenses --format=json').read()\nprint(json_output[:1000])\n\n# Get a summary of licenses by count\nprint(\"\\n--- License Summary ---\")\nos.system('pip-licenses --summary')\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}