Specifying a Python Version
Last updated May 04, 2025
Table of Contents
By default, newly created Python apps use the latest patch version of Python 3.13.
For Cedar-generation apps, subsequent builds of the app get pinned to that initial major Python version unless you specify a different version or clear the build cache.
For Fir-generation apps, subsequent builds of the app use the default Python version at the time of the build, and so the version used can change over time.
We strongly recommend that you specify a Python version for your app in
a .python-version
file instead of relying on the default version.
Selecting a Runtime
To specify a Python version, add a .python-version
file to your app’s root directory that declares the Python version number to use.
This Python version can be either:
- The major version only, for example:
3.13
(recommended) - An exact patch version, for example:
3.13.999
We strongly recommend that you specify only the major Python version (e.g. 3.13
) instead of pinning
to an exact patch version, so that your app automatically receives Python security updates each time it builds.
For example:
$ cat .python-version
3.13
To check which version of Python you’re running locally, activate your virtual environment and run python --version
.
The runtime.txt
file is deprecated.
If your app uses it, we recommend switching to a .python-version
file instead,
since it’s more widely supported by other tooling in the Python ecosystem.