{
  "id": "python/pip-venv-externally-managed-environment",
  "signature": "error: externally-managed-environment\n\n× This environment is externally managed\n╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.",
  "signature_zh": "错误：外部管理环境\n\n× 此环境由外部管理\n╰─> 要系统级安装 Python 包，请尝试 apt install python3-xyz，其中 xyz 是你要安装的包。",
  "regex": "error:\\ externally\\-managed\\-environment\\\n\\\n×\\ This\\ environment\\ is\\ externally\\ managed\\\n╰─>\\ To\\ install\\ Python\\ packages\\ system\\-wide,\\ try\\ apt\\ install\\ python3\\-xyz,\\ where\\ xyz\\ is\\ the\\ package\\ you\\ are\\ trying\\ to\\ install\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "PEP 668: the OS marks its Python installation as externally managed (via EXTERNALLY-MANAGED marker), so pip refuses to install into system site-packages.",
  "root_cause_type": "generic",
  "root_cause_zh": "PEP 668：操作系统通过 EXTERNALLY-MANAGED 标记将其 Python 安装标记为外部管理，因此 pip 拒绝安装到系统 site-packages。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Overrides the safety guard and can break OS tooling that depends on system packages.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Still blocked by the externally-managed marker and risks system damage.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Create and use a virtual environment: `python -m venv .venv && source .venv/bin/activate && pip install foo`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Install via the OS package manager if available: `sudo apt install python3-foo`, or use `pipx` for CLI apps: `pipx install foo`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}