Python Behavior in Heroku
Last updated December 03, 2024
Table of Contents
The Heroku Platform uses the Python buildpack to build Python applications. The following shows Heroku’s behavior towards Python apps.
Auto-Detection
Heroku automatically recognizes your app as a Python app if it includes one of these files in its root directory:
requirements.txt
poetry.lock
Pipfile.lock
(for apps that use classic buildpacks)
Build Behavior
The Python buildpack detects which package manager your app uses based on the files included in the root directory of the app.
If your app includes a requirements.txt
file, it uses pip to install your dependencies:
$ pip install -r requirements.txt
If your app includes a poetry.lock
file, it uses Poetry to install your dependencies:
$ poetry install --sync --only main
For apps that use classic buildpacks, if your app includes a Pipfile.lock
file, it uses Pipenv to install your dependencies:
$ pipenv install --deploy
If you have auto-provisioning enabled on your account and meet these requirements, a Heroku Postgres database automatically provisions on the first deployment of your app. To learn more, see Python Database Auto-Provisioning.