Heroku Python Support
Last updated 23 March 2017
This document describes the general behavior Heroku as it relates to the recognition and execution of Python applications. Pure Python applications, such as headless processes and evented web frameworks like Twisted, are fully supported. All versions of Django are fully supported. Django applications are detected by the presence of a
manage.py file within the repository.
For a tutorial, see Getting Started with Python on Heroku.
The Heroku Python Support will be applied to applications only when the application has a
requirements.txt in the root directory. Even if an application has no module dependencies, it should include an empty
requirements.txt to document that your app has no dependencies.
When a deployed application is recognized as a Python application, Heroku responds with
-----> Python app detected.
$ git push heroku master -----> Python app detected
web process types are created if a Python application is detected. See the Getting Started with Python on Heroku tutorial for information about how to set up your
Supported Python Runtimes
Newly created Python applications default to the Python 2.7.13 runtime.
You can specify an arbitrary version of Python to be used to run your application. This functionality is enabled by the presence of a
$ cat runtime.txt python-2.7.13
Unsupported runtimes can also be specified (e.g.
pypy3-5.5.0). However, we only endorse and support the use of Python 2.7.13 and 3.6.0.
If you specify a different Python runtime than a previous build, your application’s build cache will be purged.
The following libraries are used by the platform for managing and running Python applications and cannot be specified.
- Setuptools 32.1.0: Python packaging tools.
- Pip 9.0.1: Application dependency resolution.
The following command is run on your app to resolve dependencies:
$ pip install -r requirements.txt
.heroku directory is cached between pushes to speed up package installation.
For Django applications, a Heroku Postgres
hobby-dev database is automatically provisioned. This populates the
DATABASE_URL environment variable.
No add-ons are automatically provisioned if a pure Python application is detected. If you need a SQL database for your app, add one explicitly:
$ heroku addons:create heroku-postgresql:hobby-dev