[英]How can I install fastapi properly?
I want to install fastapi using pip in VsCode using我想在 VsCode 中使用 pip 安装 fastapi
pip install fastapi[all]
but I am getting this huge error.但我收到了这个巨大的错误。 What am I doing wrong?我究竟做错了什么?
ERROR: Command errored out with exit status 1:
command: 'C:\Users\krish\Desktop\Codes\API\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"'; __file__='"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\krish\AppData\Local\Temp\pip-record-wvba_iw2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\krish\Desktop\Codes\API\venv\include\site\python3.10\httptools'
cwd: C:\Users\krish\AppData\Local\Temp\pip-install-eqmneh6a\httptools_b8491d7c29264d1c9eb72c9367d56d7a\
Complete output (25 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.10
creating build\lib.win-amd64-3.10\httptools
copying httptools\_version.py -> build\lib.win-amd64-3.10\httptools
copying httptools\__init__.py -> build\lib.win-amd64-3.10\httptools
creating build\lib.win-amd64-3.10\httptools\parser
copying httptools\parser\errors.py -> build\lib.win-amd64-3.10\httptools\parser
copying httptools\parser\__init__.py -> build\lib.win-amd64-3.10\httptools\parser
running egg_info
writing httptools.egg-info\PKG-INFO
writing dependency_links to httptools.egg-info\dependency_links.txt
writing requirements to httptools.egg-info\requires.txt
writing top-level names to httptools.egg-info\top_level.txt
reading manifest file 'httptools.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'httptools.egg-info\SOURCES.txt'
copying httptools\parser\parser.c -> build\lib.win-amd64-3.10\httptools\parser
copying httptools\parser\url_parser.c -> build\lib.win-amd64-3.10\httptools\parser
running build_ext
building 'httptools.parser.parser' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\krish\Desktop\Codes\API\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"'; __file__='"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\krish\AppData\Local\Temp\pip-record-wvba_iw2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\krish\Desktop\Codes\API\venv\include\site\python3.10\httptools' Check the logs for full command output.
u install 'uvicorn' differently?你以不同的方式安装'uvicorn'?
Try to do these commands:尝试执行以下命令:
pip install "uvicorn[standard]" pip 安装“uvicorn[标准]”
The library needs the VC v14+ runtime library, not VS build tools.该库需要 VC v14+ 运行时库,而不是 VS 构建工具。 You can get the runtime from the MS downloads page.您可以从 MS 下载页面获取运行时。 Install the VS 2015/2017/2019 redist as it is the latest version.安装 VS 2015/2017/2019 redist,因为它是最新版本。
You can install poetry, which is a new python dependency management tool (equivalent to yarn / npm for Node.js and bundler for ruby) that makes it easier to manage dependencies in your project and beats pip by a mile. You can install poetry, which is a new python dependency management tool (equivalent to yarn / npm for Node.js and bundler for ruby) that makes it easier to manage dependencies in your project and beats pip by a mile. It is also very easy to install.它也很容易安装。
# install command pip install poetry
# Verify the installed version poetry --version
poetry add fastapi uvicorn[standard]
# zsh USE: poetry add fastapi "uvicorn[standard]"
enter image description here在此处输入图像描述
When poetry installs the dependencies, they are documented in the pyproject.toml file.当诗歌安装依赖项时,它们记录在 pyproject.toml 文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.