我是学习 FastAPI 的新手,一开始我就被卡住了。我不断收到以下错误:
(venv) root@Xue:/home/proyectos/FastAPI# uvicorn main.py:app --reload
Traceback (most recent call last):
File "/usr/bin/uvicorn", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
def _initialize_master_working_set():
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
ws.require(__requires__)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'uvloop>=0.14.0' distribution was not found and is required by uvicorn
这是我的python代码:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def home():
return {'Hello': 'World'}
我已经尝试过pip install -U uvloop pip, pip install uvloop==0.14.0
但没有修复。