{"library":"pip","title":"pip","description":"pip is the PyPA-recommended package installer for Python. It installs packages from the Python Package Index (PyPI) and other indexes, supporting wheels, source distributions, VCS URLs, and local paths. Current version is 26.0.1 (bundled with CPython via ensurepip). Releases follow a roughly quarterly cadence aligned with CPython releases. pip is primarily a CLI tool; it intentionally exposes no stable programmatic Python API.","language":"python","status":"active","last_verified":"Tue May 19","install":{"commands":[],"cli":{"name":"pip","version":null}},"imports":["import subprocess, sys\nsubprocess.check_call([sys.executable, '-m', 'pip', 'install', 'requests'])","from importlib.metadata import version, packages_distributions\nversion('requests')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport sys\n\n# Correct way to invoke pip programmatically — always use sys.executable\n# so the right interpreter/venv is targeted.\ndef pip_install(*packages):\n    subprocess.check_call(\n        [sys.executable, '-m', 'pip', 'install', *packages],\n    )\n\n# Example: install/upgrade a package\npip_install('requests>=2.31')\n\n# Verify the installed version using importlib.metadata (no pkg_resources)\nfrom importlib.metadata import version\nprint('requests', version('requests'))\n\n# List outdated packages (machine-readable JSON)\nresult = subprocess.run(\n    [sys.executable, '-m', 'pip', 'list', '--outdated', '--format=json'],\n    capture_output=True, text=True, check=True,\n)\nimport json\noutdated = json.loads(result.stdout)\nfor pkg in outdated:\n    print(f\"{pkg['name']} {pkg['version']} -> {pkg['latest_version']}\")\n","lang":"python","description":"Correct programmatic usage of pip via subprocess. pip has no supported public Python API; always call it through sys.executable to target the active interpreter or venv.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}