{"id":21692,"library":"pip-licenses-lib","title":"pip-licenses-lib","description":"A library to retrieve the software license list of Python packages installed with pip. Provides programmatic access to license metadata, with support for PEP 639, PEP 770, and SBOM files. Current version 1.1.0, requires Python >=3.10, released approximately every few months.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/stefan6419846/pip-licenses-lib","tags":["licenses","pip","metadata","compliance","sbom"],"install":[{"cmd":"pip install pip-licenses-lib","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The only public API function — returns list of Package dataclass instances.","symbol":"get_packages","correct":"from pip_licenses_lib import get_packages"},{"note":"Package is a dataclass defined in the models submodule; importing directly from the top-level fails.","wrong":"from pip_licenses_lib import Package","symbol":"Package","correct":"from pip_licenses_lib.models import Package"}],"quickstart":{"code":"from pip_licenses_lib import get_packages\n\npackages = get_packages()\nfor pkg in packages[:5]:\n    print(pkg.name, pkg.license_expression, pkg.version)","lang":"python","description":"Retrieve license info for all installed packages and print first 5 (name, license expression, version)."},"warnings":[{"fix":"Upgrade to >=0.3.0 and use object attributes (e.g., pkg.name, pkg.version) instead of dictionary subscripting.","message":"In v0.3.0, the return type changed from dict to dataclass (Package). Attribute names were renamed to match PEP8. Code accessing dict keys or old attribute names will break.","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Use from pip_licenses_lib.models import Package.","message":"Package model is not importable from the top-level; must import from pip_licenses_lib.models.Package. Doing from pip_licenses_lib import Package raises ImportError.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Upgrade Python to >=3.10 for latest version.","message":"Python <=3.9 support dropped in v0.5.0; Python <=3.9 dropped again in v1.0.0 (now requires >=3.10).","severity":"deprecated","affected_versions":"<0.5.0, 0.5.0-0.6.0 require >=3.9, <1.0.0 requires >=3.9, >=1.0.0 requires >=3.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Update code to use attribute access: pkg.name, pkg.version, etc.","cause":"Using old dict-style access on a Package dataclass after upgrading from <0.3.0.","error":"AttributeError: 'Package' object has no attribute 'name'"},{"fix":"Use 'from pip_licenses_lib.models import Package' instead.","cause":"Attempting to import Package from top-level package instead of the models submodule.","error":"ImportError: cannot import name 'Package' from 'pip_licenses_lib'"},{"fix":"Access fields using dot notation: pkg.name, pkg.version, etc.","cause":"Trying to use square brackets on a Package dataclass instance (e.g., pkg['name']).","error":"TypeError: 'Package' object is not subscriptable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}