Installing Python packages with pip
As we said earlier, pip
is the built-in Python package manager that will help us install third-party libraries. To get started, let's install FastAPI and Uvicorn:
$ pip install fastapi uvicorn[standard]
We'll talk about it in later chapters, but Uvicorn is required to run a FastAPI project.
Tip
You have probably noticed the word standard
inside square brackets just after uvicorn
. Sometimes, some libraries have sub-dependencies that are not required to make the library work. Usually, they are needed for optional features or specific project requirements. The square brackets are here to indicate that we want to install the standard
sub-dependencies of uvicorn
.
To make sure the installation worked, we can open a Python interactive shell and try to import the FastAPI
package:
$ python >>> from fastapi import FastAPI
If it passes without any errors, congratulations, FastAPI is installed and ready to use!