{
  "id": "python/fastapi-missing-starlette-import",
  "signature": "ImportError: cannot import name 'HTTPException' from 'fastapi'",
  "signature_zh": "导入错误：无法从 'fastapi' 导入名称 'HTTPException'",
  "regex": "ImportError:\\ cannot\\ import\\ name\\ 'HTTPException'\\ from\\ 'fastapi'",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "HTTPException is actually from starlette, not fastapi directly in some versions.",
  "root_cause_type": "generic",
  "root_cause_zh": "在某些版本中，HTTPException实际上来自starlette，而不是直接来自fastapi。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Installing an older version of fastapi that has HTTPException.",
      "why_fails": "The import path may have changed; older versions may still have it.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Assuming it's a bug and reinstalling fastapi.",
      "why_fails": "Reinstalling may not fix the import path issue.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Import HTTPException from starlette instead.",
      "success_rate": 0.95,
      "how": "from starlette.exceptions import HTTPException",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use fastapi's HTTPException if available; check version.",
      "success_rate": 0.85,
      "how": "from fastapi import HTTPException  # Works in recent versions",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-08-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}