Python
The Python language is officially supported on the platform.
Detection
To ensure our deployment system considers your application as a Python
application, a file Pipfile, requirements.txt, setup.py, poetry.lock or
uv.lock should be present at the root of your project, defining the
dependencies of your app.
Python Versions
Availability
The following versions of Python are available:
| Python Version |
scalingo-20 (EOL) |
scalingo-22 |
scalingo-24 |
|---|---|---|---|
3.14 |
Unsupported | up to 3.14.0
|
up to 3.14.0
|
3.13 |
up to 3.13.3
|
up to 3.13.9
|
up to 3.13.9
|
3.12 |
up to 3.12.10
|
up to 3.12.12
|
up to 3.12.12
|
3.11 |
up to 3.11.12
|
up to 3.11.14
|
up to 3.11.14
|
3.10 |
up to 3.10.17
|
up to 3.10.19
|
up to 3.10.19
|
Selecting a Version
The default Python version on all stacks is the latest 3.13 version.
You can, however, instruct the platform to use another version.
The buildpack looks for a Python version in the following places (in descending order of precedence):
- The
runtime.txtfile (deprecated) - The
.python-versionfile (recommended) - The
python_full_versionfield in thePipfile.lockfile (Pipenv users only) - The
python_versionfield in thePipfile.lockfile (Pipenv users only)
To instruct the platform to use a specific Python runtime, add a
.python-version file to your app’s root directory and declare the Python
version number to use in it.
This version can be either:
- The major Python version such as
3.12(recommended) - The full Python version such as
3.12.7
Dependencies
Recommended: pipenv
When the project is using pipenv and contains a Pipfile and a
Pipfile.lock files, the following command is used to install dependencies:
pipenv install
Legacy: requirements.txt
If a requirements.txt file is present in your application, the dependencies
will be installed respecting this file with:
pip install -r requirements.txt
Alternative: Poetry
If your project uses poetry and contains a poetry.lock file, the following command is used to install dependencies:
poetry sync --compile
Frameworks
We handle most of the common frameworks. Obviously, Django is among them. You need to
configure your application to bind the port defined by the environment variable $PORT.
Specific Python Buildpack Hooks
You may want to trigger custom actions after a successful deployment. The postdeploy hook is exactly what you need. But your application may require some actions to be executed during the deployment.
The Python buildpack can execute two hooks: before and after the installation of Python and its
dependencies. They must be located in the bin root folder of your application and be named
pre_compile and post_compile.
Buildpack
More information at https://github.com/Scalingo/python-buildpack.
WEB_CONCURRENCY
The default level of concurrency is automatically defined, depending on the amount of memory available in the container running the app:
| Container Size | Memory (MB) | Default Concurrency |
|---|---|---|
| S | 256 | 1 |
| M | 512 | 2 |
| L | 1024 | 4 |
| XL | 2048 | 8 |
| 2XL | 4096 | 16 |
For further details about this calculation, please see the WEB_CONCURRENCY.sh script of the Python buildpack.
To override the automatically defined value, set the WEB_CONCURRENCY environment variable to the desired value.