Playbook
Install Python
Python 3 from the distribution, with venv, pip and the headers extensions compile against.
Category
Runtimes
Time limit per server
20 minutes
Temporary failures
Retried automatically, up to 2 times
Version
1.0
Supported systems
Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+
Options
As they appear on the run form, with their defaults.
Python
One choice
On Ubuntu and Debian, both choices install the release's one Python 3.
- Newest Python 3 in the distribution's repositories
- The distribution's default python3
Default: Newest Python 3 in the distribution's repositories
When to use it
Before running a Python application or installing Gunicorn, uv, Poetry or Pipenv. The Python Production Stack template runs it first.
Choosing the options
Python
- Newest Python 3 in the distribution's repositories — on the RHEL family and Amazon Linux, installs the newest Python packaged beside the system one:
python3.13,python3.12orpython3.11, whichever the repositories offer first. Choose this for new applications. - The distribution's default python3 — the Python the operating system itself uses, for example 3.9 on RHEL-compatible 9. Choose it only when an application must run on exactly that version.
On Ubuntu and Debian both choices install the release's one Python 3 (3.12 on Ubuntu 24.04, 3.11 on Debian 12), because those distributions package one per release.
Use the same choice when you later run Install Gunicorn and Install Python Tools, so they use the same interpreter.
What it does on the server
- Installs the interpreter with venv, pip and the development headers:
python3,python3-venv,python3-pip,python3-devon Ubuntu and Debian;python3.12,python3.12-pip,python3.12-devel(or the version chosen) on the RHEL family. - Creates a throwaway virtual environment and installs into it with pip, to prove both work, then removes it.
The system python3 is never replaced: the RHEL family and Amazon Linux run their own tools with it. Nothing is downloaded from outside the distribution.
After the run
Create each application's virtual environment with the interpreter the result names, for example python3.12 -m venv /srv/api/venv.
Common problems
"No newer Python than python3 is available from this server's repositories, so python3 is installed." — The distribution offers no newer Python. The default is installed instead; nothing is wrong.
"Python … could not create a virtual environment (above)." — The venv module is broken or missing. The output above shows Python's own error.