背景

from pydantic import BaseModel, EmailStr

class UserIn(BaseModel):
    username: str
    password: str
    email: EmailStr
    full_name: Optional[str] = None

定义的 Pydantic Model 某个字段声明为 EmailStr 类型

运行 uvicorn 服务器的时候报错

ImportError: email-validator is not installed, run `pip install pydantic[email]`

 

根因

缺少 email_validator 库

 

解决方法

pip install email_validator

 

注意

虽然它提示了解决方法,但很大可能会提示你

> pip install pydantic[email]  
zsh: no matches found: pydantic[email]

 

相关文章:

  • 2021-11-30
  • 2021-09-19
  • 2021-09-12
  • 2021-05-17
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-21
  • 2021-05-26
  • 2021-05-21
  • 2021-07-16
  • 2021-06-15
  • 2022-12-23
相关资源
相似解决方案