python
install_error
ai_generated
true
ImportError: 未安装 email-validator,请运行 `pip install pydantic[email]`
ImportError: email-validator is not installed, run `pip install pydantic[email]`
ID: python/fastapi-attribute-error-email-validator
80%修复率
90%置信度
0证据数
2024-07-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
Pydantic 模型使用了 `EmailStr`,它依赖可选的 `email-validator` 包。
English
A Pydantic model uses `EmailStr`, which requires the optional `email-validator` dependency.
解决方案
-
98% 成功率
pip install 'pydantic[email]'
-
97% 成功率
echo 'pydantic[email]' >> requirements.txt && pip install -r requirements.txt
无效尝试
常见但无效的做法:
-
70% 失败
Loses email validation; invalid emails pass through to the DB.
-
95% 失败
Wrong package name; installs an unrelated module.