Specifying a Python Version
Last updated December 10, 2024
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 runtime, add a .python-version
file (note the leading .
in the filename) to your
app’s root directory that declares the Python version number to use.
This version can be either:
- The major Python version such as
3.13
(recommended) - The full Python version such as
3.13.0
We recommend specifying only the major version (e.g. 3.13
), so that your app is automatically built with the
latest Python security patches.
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
:
$ python --version
Python 3.13.0
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.