-1

I want to install fastapi using pip in VsCode using

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.
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Krishna
  • 83
  • 1
  • 8
  • 5
    The error message says "Microsoft Visual C++ 14.0 or greater is required. Get it with Microsoft C++ Build Tools". Have you done that? – enzo Dec 26 '21 at 13:49
  • I installed Microsoft Visual C++ 19 and I'm getting the same error. – Krishna Dec 26 '21 at 13:59
  • 1
    Did you specifically select/enable the Build Tools as part of the installation? See: https://stackoverflow.com/a/55575792/2745495 – Gino Mempin Dec 26 '21 at 14:03
  • 1
    Does this answer your question? [Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)](https://stackoverflow.com/questions/29846087/microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat) – Gino Mempin Dec 26 '21 at 14:04

4 Answers4

4

The solution from this post worked:

pip install --only-binary :all: fastapi[all]
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Krishna
  • 83
  • 1
  • 8
1

u install 'uvicorn' differently?

  • Try to do these commands :

    pip install "uvicorn[standard]"

  • The library needs the VC v14+ runtime library, not VS build tools. You can get the runtime from the MS downloads page. Install the VS 2015/2017/2019 redist as it is the latest version.

  • The question was about fastapi, and from the error message it is about missing "*Microsoft C++ Build Tools*" – Gino Mempin Dec 26 '21 at 13:57
  • I don't want to install everything separately. The fastapi documentation says to use fastapi[all] to install everything at once. BTW It still gives the same error. – Krishna Dec 26 '21 at 14:03
0

Installing fastapi[all] FROM VS Code

From a Notebook Code Cell in VS Code

You might have only been missing the exclamation mark and/or the quotes ...

!pip install "fastapi[all]"

From a Terminal Shown Within VS Code

$ pip install "fastapi[all]"

Both worked for me from VS Code installed on Linux Mint 20.3

The same principles apply for uvicorn[standard] when you install that.

Thom Ives
  • 3,642
  • 3
  • 30
  • 29
-3

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.

Conjure.Li
  • 38
  • 3
  • 1
    poetry or pipenv and most other package managers still use pip internally. The issue is with this part of the error message: "*error: Microsoft Visual C++ 14.0 or greater is required.*" which will still happen with poetry. The OP is trying to install `fastapi[all]` which seems to require compiling from source. – Gino Mempin Dec 26 '21 at 14:33
  • No, I don't agree with you, I just provided the viable solution and I use it all the time. Thanks. – Conjure.Li Dec 26 '21 at 14:35
  • The question was "What am I doing wrong?" he didn't ask tell me how to do this differently, or how you do it. – Plazgoth Jun 11 '22 at 11:25