Specifying a Python Version for Cloud Foundry

When you use Cloud Foundry to build Python based solutions like Django, you end up running into the issue of Python versions. By default Cloud Foundry, defaults the Python version to 2.7.11. Between version 2.7.11 and the latest 3.5.x, Python has made a lot of changes and even simple string processing functions could potentially error out.

Create a runtime.txt

The best way to solve for this is to create a runtime.txt in the root folder of your application. This is the same location where you have the manifest.yml file. In the runtime.txt file, specify the following line:

Modify your manifest.yml

The Python buildpack available on GitHub already has this information but just in case you removed it (like I did), please add this back.

Lastly

Remember that although you’ve specified the Python version, it doesn’t mean that Cloud Foundry (or) an adoption of Cloud Foundry support that version. For example, Predix supports up to 3.4.4 and IBM BlueMix upto 3.5.1. Always refer to the provider’s documentation. If the documentation is not available, you may have to increment the version from 2.7.11 (bit-by-bit) until the system begins to error out.

Have fun!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.