Heroku Python Support
Last updated 01 June 2020
Table of Contents
Heroku supports all popular web frameworks for Python (Django, Flask, Pyramid, and so on).
For a deployment tutorial that uses a sample Django app, see Getting Started on Heroku with Python.
Recognizing a Python app
Heroku automatically recognizes your app as a Python app if it includes a
setup.py file in its root directory.
When a deployed application is recognized as a Python application, you’ll see this in the build output:
$ git push heroku master -----> Python app detected
Specifying a Python version
By default, newly created Python apps use the
python-3.6.10 runtime. You can also specify a different supported Python version.
python-3.8.3on all supported runtime stacks
python-3.7.7on all supported runtime stacks
python-3.6.10on all supported runtime stacks
python-2.7.18on all supported runtime stacks
Python 2 has reached its community-specified end of life and all apps should be migrated to Python 3 as soon as possible.
Beta Support: PyPy
PyPy version 7.3.1 has been beta released on the platform. The following runtimes of PyPy are available for use on Heroku:
Supported PyPy runtimes:
pypy2.7-7.3.1on all supported runtime stacks
pypy3.6-7.3.1on all supported runtime stacks
These are still in Beta stage and thus are an experimental feature. To use these runtimes, your
runtime.txt file must list these distributions as shown or it will fail your build.
If your app includes a
requirements.txt file, Heroku runs the following command to resolve dependencies:
$ pip install -r requirements.txt
For Django applications, a Heroku Postgres
hobby-dev database is automatically provisioned. This populates your app’s
DATABASE_URL config var.
A Heroku Postgres database is not automatically provisioned for other Python apps, but you can easily provision one manually.