# 导入错误：无法从 'pydantic' 导入名称 'BaseModel'

- **ID:** `python/fastapi-import-error-pydantic`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Pydantic版本过旧或未安装；BaseModel从v1版本开始引入。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Upgrade pydantic to a recent version.** (95% 成功率)
   ```
   pip install --upgrade pydantic
   ```
2. **If using pydantic v2, import from pydantic.v1.** (85% 成功率)
   ```
   from pydantic.v1 import BaseModel
   ```

## 无效尝试

- **Installing an older version of pydantic that does not have BaseModel.** — BaseModel is a core feature; older versions may not have it. (70% 失败率)
- **Trying to import from pydantic.dataclasses instead.** — That is a different feature; BaseModel is the standard way. (60% 失败率)
