{
  "id": "python/fastapi-pydantic-v1-v2-mismatch",
  "signature": "PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.0/migration/ for more details.",
  "signature_zh": "PydanticImportError: `BaseSettings` 已移至 `pydantic-settings` 包。详情见 https://docs.pydantic.dev/2.0/migration/。",
  "regex": "PydanticImportError:\\ `BaseSettings`\\ has\\ been\\ moved\\ to\\ the\\ `pydantic\\-settings`\\ package\\.\\ See\\ https://docs\\.pydantic\\.dev/2\\.0/migration/\\ for\\ more\\ details\\.",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "Code written for Pydantic v1 imports BaseSettings from pydantic, but Pydantic v2 moved it to a separate package.",
  "root_cause_type": "generic",
  "root_cause_zh": "为 Pydantic v1 编写的代码从 pydantic 导入 BaseSettings，但 Pydantic v2 将其移至独立包。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "FastAPI latest requires v2 features; downgrade cascades.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Import still fails at class definition time.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "pip install pydantic-settings; from pydantic_settings import BaseSettings",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Set model_config = SettingsConfigDict(env_file='.env') instead of class Config",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}