FastAPI - 解决运行 uvicorn 报错 ImportError: email-validator is not installed, run `pip install pydantic[email]`

简介: FastAPI - 解决运行 uvicorn 报错 ImportError: email-validator is not installed, run `pip install pydantic[email]`

背景


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 isnot installed, run `pip install pydantic[email]`

 

根因

缺少 email_validator 库

 

解决方法


pip install email_validator

 

注意

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

> pip install pydantic[email]  

zsh: no matches found: pydantic[email]

相关文章
|
3月前
|
异构计算 Python
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
334 1
|
3月前
|
人工智能 Shell Python
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
ERROR: pip’s dependency resolver does not currently take into 报错-Python项目依赖冲突的解决方案-优雅草优雅草卓伊凡
233 0
|
11月前
|
安全 应用服务中间件 API
Ascend+FastAPI+ Uvicorn 实现推理
FastAPI 是一个高性能的 Python Web 框架,专为构建 RESTful API 设计,支持异步编程和数据验证。Uvicorn 是基于 ASGI 的轻量级异步服务器,与 FastAPI 结合使用可提供高效、高并发的服务。在生产环境中,二者配合 Nginx 可实现稳定安全的部署。示例代码展示了如何通过 FastAPI 和 Uvicorn 启动服务,并在 Ascend 平台上运行推理模型,处理自然语言任务。 简介字数:239
|
Docker Python Windows
pycharm使用fastapi/uvicorn无法reload的问题
这篇文章讨论了在PyCharm中使用FastAPI和uvicorn时遇到的无法快速重载的问题,并提供了包括降级uvicorn版本和使用命令行运行等解决方法。
pycharm使用fastapi/uvicorn无法reload的问题
|
Linux Shell Python
centos执行pip3 install etcd3报错
centos执行pip3 install etcd3报错
|
缓存 Python
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-npf9报错
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-npf9报错
|
开发者 Python
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
1293 0
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
|
安全 Python
【Python】 已解决:(pip提示)[notice] To update, run: python.exe -m pip install --upgrade pip
【Python】 已解决:(pip提示)[notice] To update, run: python.exe -m pip install --upgrade pip
1491 0
【Python】 已解决:(pip提示)[notice] To update, run: python.exe -m pip install --upgrade pip
|
Ubuntu Python
ubuntu build install python3.12 and config pip
该脚本用于在 Ubuntu 上编译安装 Python 3.12,并配置 pip 使用国内镜像源。主要步骤包括安装依赖、下载并解压 Python 源码、编译安装、创建符号链接、配置 pip 源,以及验证安装和更新 pip。通过运行此脚本,可以快速完成 Python 3.12 的安装和配置。
1420 0
|
安全 网络安全 Python
【Python】已解决:(pip安装库报错)ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访
【Python】已解决:(pip安装库报错)ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访
2940 0

热门文章

最新文章