{
  "id": "python/fastapi-pydantic-v1-v2-incompat",
  "signature": "pydantic.errors.PydanticUserError: `BaseSettings` has been moved to the `pydantic-settings` package.",
  "signature_zh": "pydantic.errors.PydanticUserError: `BaseSettings` 已移至 `pydantic-settings` 包。",
  "regex": "pydantic\\.errors\\.PydanticUserError:\\ `BaseSettings`\\ has\\ been\\ moved\\ to\\ the\\ `pydantic\\-settings`\\ package\\.",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Project upgraded to Pydantic v2 (required by FastAPI 0.100+) but code still imports BaseSettings from pydantic.",
  "root_cause_type": "generic",
  "root_cause_zh": "项目升级到了 Pydantic v2（FastAPI 0.100+ 要求），但代码仍从 pydantic 导入 BaseSettings。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Conflicts with FastAPI's dependency requirement and breaks other packages.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "It's a raised exception, not a warning; import still fails.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pip install pydantic-settings\nfrom pydantic_settings import BaseSettings",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "class Settings(BaseSettings):\n    model_config = SettingsConfigDict(env_file='.env')",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}