Updated: Mar 25, 2020
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.
url_to_dependency_map: - match: python-(d+.d+.d+) name: python version: 3.5.2 - match: libmemcache name: libmemcache version: 1.0.18 - match: libffi name: libffi version: "3.1" dependencies: - name: libmemcache version: 1.0.18 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/python/binaries/cflinuxfs2/libmemcache.tar.gz md5: 6b40600ab7c5bd52b5c6eedd18efb651 - name: libffi version: "3.1" cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/python/binaries/cflinuxfs2/libffi.tar.gz md5: 83028a299b8ac323bda8a56c5c70d4cd - name: python version: 2.7.11 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-2.7.11-linux-x64.tgz md5: 6a93c298ce97d4eb6b3ec7039f9ae439 - name: python version: 2.7.12 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-2.7.12-linux-x64.tgz md5: 5b49c4c1ba9ceae55f5d4bd0b95863f4 - name: python version: 3.3.5 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.3.5-linux-x64.tgz md5: f32e11f2d039dae0d6574403a80b485d - name: python version: 3.3.6 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.3.6-linux-x64.tgz md5: 08dee09d32477c7f0497e736c0c7967b - name: python version: 3.4.4 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.4.4-linux-x64.tgz md5: eeeaf592c843fbc05528d782f20486fc - name: python version: 3.4.5 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.4.5-linux-x64.tgz md5: 119671dbbb94170e69da5f3247f6ee6e - name: python version: 3.5.1 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.5.1-linux-x64.tgz md5: a292283d7eec49d7ea5c60036f633740 - name: python version: 3.5.2 cf_stacks: - cflinuxfs2 uri: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/python/python-3.5.2-linux-x64.tgz md5: 701a135b3228075c2ce59c527bc92e1e
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.