gpt4 book ai didi

Python uvicorn : The term 'uvicorn' is not recognized as the name of a cmdlet, 函数,脚本文件

转载 作者:行者123 更新时间:2023-12-04 14:10:26 31 4
gpt4 key购买 nike

晚上好,
我正在使用 python 3.9 并尝试根据 Internet 上的文档在 Windows 10 Pro 上运行新的 FastAPI 服务 https://www.uvicorn.org/我执行了以下语句

pip install uvicorn pip install uvicorn[standard]
创建示例文件 app.py
from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def root():
return {"message": "Hello World"}
但是当我运行下面的代码时:
uvicorn main:app --reload


uvicorn : The term 'uvicorn' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify t
hat the path is correct and try again.
At line:1 char:1
+ uvicorn
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (uvicorn:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我还在环境设置中添加了Python的路径
我还重新安装了 Python 3.9 并将安装的默认路径设置为 c:\ProgramFiles\Python39 此路径现在也包含在系统环境和用户环境设置中。
enter image description here
如果我再次运行 pip install uvicorn 它会显示以下语句:
λ pip install uvicorn
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: uvicorn in c:\users\username\appdata\roaming\python\python39\site-packages (0.12.2)
Requirement already satisfied: h11>=0.8 in c:\users\username\appdata\roaming\python\python39\site-packages (from uvicorn) (0.11.0)
Requirement already satisfied: click==7.* in c:\users\username\appdata\roaming\python\python39\site-packages (from uvicorn) (7.1.2)
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the 'c:\program files\python39\python.exe -m pip install --upgrade pip' command.
非常感谢
埃里克

最佳答案

您也可以运行 uvicorn使用以下命令:

python -m uvicorn main:app --reload

关于Python uvicorn : The term 'uvicorn' is not recognized as the name of a cmdlet, 函数,脚本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64936440/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com