Specifying a Python Runtime

Last Updated: 17 March 2014

Table of Contents

If you have questions about Python on Heroku, consider discussing it in the Python on Heroku forums. Both Heroku and community-based Python experts are available.

When you push a Python application to Heroku, Python 2.7.6 will be used by default:

-----> No runtime.txt provided; assuming python-2.7.6.
-----> Preparing Python runtime (python-2.7.6)
-----> Installing Setuptools (2.1)
-----> Installing Pip (1.5.4)
-----> Installing dependencies using Pip
...

Specifying a specific 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 runtime.txt file.

$ cat runtime.txt
python-3.4.0

When you commit and push to Heroku you’ll see that Python 3.4.0 is detected:

-----> Heroku receiving push
-----> Python app detected
-----> Preparing Python runtime (python-3.4.0)
-----> Installing Setuptools (2.1)
-----> Installing Pip (1.5.4)
-----> Installing dependencies using Pip
...

Supported runtimes

Supported runtimes include:

  • python-2.7.6
  • python-3.4.0
  • pypy-1.9 (experimental)

Unsupported runtimes can also be specified (2.4.4–3.4.0). However, we only endorse and support the use of Python 2.7.6 and 3.4.0.

Changing runtimes

If you specify a different Python runtime than a previous build, your application’s build cache will be purged.