Skip to main content
FastAPI Docs

Search documentation

Type to search this documentation.

On this pageOverview

Virtual Environments

When you work with Python projects, you should use a virtual environment to isolate the packages installed for each project.

For FastAPI projects, I recommend using uv to manage the project, its dependencies, and its virtual environment.

Install uv using the official installation guide, and then create a project:

console
$ uv init awesome-project --bare
$ cd awesome-project
$ uv add "fastapi[standard]"

uv creates a virtual environment for the project automatically. You don't need to create or activate one yourself.

Run commands inside the project environment with uv run, for example:

console
$ uv run fastapi dev

Read the Virtual Environments guide to learn how virtual environments work underneath, including activation and the alternative python -m venv and pip workflow.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu