Page last updated:
Cloud Foundry automatically uses this buildpack if it detects a
setup.py file in the root directory of your project.
If your Cloud Foundry deployment does not have the Python Buildpack installed, or the installed version is out of date, you can use the latest version by specifying it with the
-b option when you push your app. For example:
$ cf push my_app -b https://github.com/cloudfoundry/buildpack-python.git
You can find the list of supported Python versions in the Python buildpack release notes.
You can specify a version of the Python runtime by including it within a
runtime.txt file. For example:
$ cat runtime.txt python-3.5.2
The buildpack only supports the stable Python versions, which are listed in the
manifest.yml and Python buildpack release notes.
To request the latest Python version in a patch line, replace the patch version with
3.6.x. To request the latest version in a minor line, replace the minor version:
If you try to use a binary that is not currently supported, staging your app fails and you see the following error message:
Could not get translated url, exited with: DEPENDENCY_MISSING_IN_MANIFEST: ... ! ! exit ! Staging failed: Buildpack compilation step failed
The Python buildpack does not generate a default start command for your applications.
To stage with the Python buildpack and start an application, do one of the following:
Required for Cloud Foundry v245 only: Supply a Procfile. For more information about Procfiles, see the Configuring a Production Server topic. The following example Procfile specifies
gunicornas the start command for a web app running on Gunicorn:
web: gunicorn SERVER-NAME:APP-NAME
Specify a start command with
-c. The following example specifies
waitress-serveas the start command for a web app running on Waitress:
$ cf push python-app -c "waitress-serve --port=$PORT DJANGO-WEB-APP.wsgi:MY-APP"
Specify a start command in the application manifest by setting the
commandattribute. For more information, see the Deploying with Application Manifests topic.
If you are deploying in an environment that is disconnected from the Internet, your application must vendor its dependencies.
For the Python buildpack, use
$ cd YOUR-APP-DIR $ mkdir -p vendor # vendors all the pip *.tar.gz into vendor/ $ pip install --download vendor -r requirements.txt --no-binary :all:
cf push uploads your vendored dependencies. The buildpack installs them directly from the
Note: To ensure proper installation of dependencies, we recommend non-binary vendored dependencies. The above
pip install command achieves this.
cfenv package provides access to Cloud Foundry application environment settings by parsing all the relevant environment variables. The settings are returned as a class instance. See https://github.com/jmcarp/py-cfenv for more information.
Miniconda Support (starting in buildpack version 1.5.6)
To use miniconda instead of pip for installing dependencies, place an
environment.yml file in the root directory.
For examples, see our sample apps:
Pipenv Support (starting in buildpack version 1.5.19)
To use Pipenv instead of pip (directly) for installing dependencies, place a
Pipfile in the root directory. Easiest to let Pipenv generate this for you.
If you need to use a proxy to download dependencies during staging, you can set
https_proxy environment variables. For more information, see the Proxy Usage Documentation.
Versions of Python 2.7.9 and later use certificates stored in
/etc/ssl/certs. Your platform operator can configure the platform to add the custom certificates into the application container.
Join the #buildpacks channel in our Slack community if you need any further assistance.
For more information about using and extending the Python buildpack in Cloud Foundry, see the python-buildpack GitHub repository.
You can find current information about this buildpack on the Python buildpack release page in GitHub.Create a pull request or raise an issue on the source for this page in GitHub