python
install_error
ai_generated
true
pydantic.errors.PydanticUserError:`EmailStr` 需要 `email-validator` 包。请使用 `pip install pydantic[email]` 安装。
pydantic.errors.PydanticUserError: `EmailStr` requires the `email-validator` package. Install it with `pip install pydantic[email]`.
ID: python/pydantic-email-str-deprecated
80%修复率
90%置信度
0证据数
2024-01-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
使用了 EmailStr,但未安装可选的 email-validator 依赖。
English
EmailStr is used but the optional email-validator dependency is not installed.
解决方案
-
98% 成功率
pip install 'pydantic[email]'
-
97% 成功率
pip install email-validator # then from pydantic import BaseModel, EmailStr class U(BaseModel): email: EmailStr
无效尝试
常见但无效的做法:
-
70% 失败
Wrong package; 'email' is a stdlib module, not a PyPI validator.
-
55% 失败
Loses email format validation; invalid addresses pass through.
-
40% 失败
Import still fails until the interpreter restarts.