Skip to content

Install Dependencies

You can define the dependencies for your FastAPI application using the standard pyproject.toml file.

If you use uv, it is supported by default, including if you use a lock file uv.lock.

If you use a standard pylock.toml lock file, it will be used to install the dependencies (via uv).

If you don’t use pyproject.toml, you could also have a requirements.txt and it will be used.

If you don’t define any dependencies, by default, FastAPI Cloud will install "fastapi[standard]" and use it.

FastAPI Cloud supports any currently supported version of Python (3.10+). By default, FastAPI Cloud uses the latest stable Python version available.

You can specify the Python version you want to use for your application in the pyproject.toml file using the requires-python field. For example, to require Python 3.12 or higher:

[project]
name = "app"
version = "0.1.0"
description = "My awesome app"
requires-python = ">=3.12"

This specifies that Python 3.12 or any newer version should be used.

There’s a chance that you are using a library that requires some build step, and it hasn’t been updated to support the latest Python versions.

In those cases, the default behavior of most Python tools is to try and download the source files for these packages and build them locally.

But this process is normally very slow, error prone, requires local system dependencies that in many cases are not available, and can even fail completely. This applies in most environments, including FastAPI Cloud, but also in your local development system.

For these cases, you would normally not see errors that tell you anything about trying an older version of Python, the errors normally would only say that the tool is downloading the source files and trying to build them, and then failing, in some cases with a cryptic error message, maybe saying something related to not finding a component for a compiler for C, Rust, C++, Cython, etc. It can get quite cryptic. 😅

To avoid these issues, you can try and pin the version of Python to the one that you are sure works with your dependencies, and upgrade it explicitly later when you can test and verify that everything works fine.

For example, if you are using a package that only works with Python up to 3.13, you can pin that version in the pyproject.toml file:

[project]
name = "app"
version = "0.1.0"
description = "My awesome app"
requires-python = "==3.13.*"

This way, FastAPI Cloud will use Python 3.13 (for example 3.13.9) to install and run your application, avoiding any potential issues with packages incompatible with newer Python versions, like 3.14.

Now, pinning your version of Python should be done only for applications, like the app you are building with FastAPI, but not for libraries, like FastAPI itself.

If you are building a library, for example, to be uploaded to PyPI and to be installed and used by others (like FastAPI itself), you should not pin the Python version. You can read (a lot) more about this in: Should You Use Upper Bound Version Constraints?.

You can also specify the Python version using a .python-version file in the root of your project.

This is (not yet) a standard, but it’s a common convention used by several tools, including uv and pyenv.