{
  "id": "python/pip-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": "install_error",
  "subcategory": null,
  "root_cause": "PEP 668 marker file (EXTERNALLY-MANAGED) exists in the system Python's stdlib, telling pip not to modify the OS-managed interpreter.",
  "root_cause_type": "generic",
  "root_cause_zh": "PEP 668 标记文件（EXTERNALLY-MANAGED）存在于系统 Python 的 stdlib 中，告诉 pip 不要修改操作系统管理的解释器。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "--user still writes into the externally-managed interpreter's user site-packages and is blocked.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Running as root does not bypass the PEP 668 marker and can corrupt OS packages.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "python3 -m venv .venv\nsource .venv/bin/activate\npython -m pip install requests",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "sudo apt install python3-requests\n# or for CLI apps\npipx install ruff",
      "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": []
}