Customizing the Python Runtime

You can use custom runtimes to add additional functionality to a Python app running in the flexible environment. To configure a custom runtime, you replace this line in your app.yaml file:

runtime: python

with this line:

runtime: custom

You must also add a Dockerfile in the same directory that contains the app.yaml file. For building Python containers, Google provides this base image:

Base Image Version Health Checks Supports App Engine APIs Notes
gcr.io/google_appengine/python Python2.7/3.5 No No This is the same image used when you specify runtime: python.

You can automatically generate the Dockerfile for your current runtime using gen-config:

gcloud beta app gen-config --custom

App Engine API support

A base image that supports the App Engine APIs supports 7 APIs in the standard (runtime: python27) App Engine runtime.

Health Checking

By default, all programs running in the flexible environment receive health check requests If a base image supports health checking, you don't need to write any additional code. If it does not, you will need to disable health checks, or write your own code to handle health check requests.

Selecting the Python version

The python runtime has Python 2.7.9 and Python 3.5.2 pre-installed. You can customize the Dockerfile to install other versions or alternative interpreters if needed.

You can specify a whether to use Python 2 or Python 3 in your application's Dockerfile when creating the virtualenv:

# Python 3
RUN virtualenv /env -p python3.5

# Python 2 (implicit)
RUN virtualenv /env

# Python 2 (explicit)
RUN virtualenv /env -p python2.7

Send feedback about...

App Engine flexible environment for Python docs