我在FastAPI上工作,发生了这个错误。
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get("/ping")
async def ping():
return "Hello, I am alive"
if __name__ == "__main__":
uvicorn.run(app, host='localhost', port=8000)
Traceback (most recent call last):
File "D:/own_thesis/training/for_api.py", line 2, in <module>
from fastapi import FastAPI
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\fastapi\__init__.py", line 7, in <module>
from .applications import FastAPI as FastAPI
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\fastapi\applications.py", line 15, in <module>
from fastapi import routing
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\fastapi\routing.py", line 22, in <module>
from fastapi.datastructures import Default, DefaultPlaceholder
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\fastapi\datastructures.py", line 3, in <module>
from starlette.datastructures import URL as URL # noqa: F401
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\starlette\datastructures.py", line 7, in <module>
from starlette.concurrency import run_in_threadpool
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\starlette\concurrency.py", line 11, in <module>
from typing_extensions import ParamSpec
ImportError: cannot import name 'ParamSpec' from 'typing_extensions' (C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\typing_extensions.py)
发布于 2022-08-29 16:48:46
只是在@arunppsg的回复中作了一个小小的错误更正:您只需运行
pip uninstall typing_extensions
pip uninstall fastapi
pip install --no-cache fastapi
问题就消失了。
小的错误更正在pip uninstall typing_extensions
中(在结尾处有s)。谢谢@arunppsg,我不能对你的评论发表评论,因为我仍然没有50点的声誉,所以我决定把它作为一个答案。如果你把你的评论转换成一个答案,你很乐意删除它。
https://stackoverflow.com/questions/72980064
复制相似问题