The Python Runtime

The Cloud Functions Python runtime is based on Python version 3.7.1. For instructions on how to prepare your local machine for Python development, see Setting Up a Python Development Environment.

To get started with Python on Cloud Functions, see the Quickstart.

Selecting the runtime

You can select the Python runtime for your function during deployment.

gcloud

If you are using the gcloud command-line tool, you can specify the runtime by using the --runtime parameter. For example:

gcloud functions deploy NAME --runtime python37 --trigger-http

For more arguments that you can specify when you are deploying, see Deploy using the gcloud tool.

Console

If you are using the GCP Console, you can select the runtime when you create and deploy a function.

  1. In the GCP Console, go to the Cloud Functions Overview page.

    Go to the Cloud Functions Overview page

    Make sure that the project for which you enabled Cloud Functions is selected.

  2. Click Create Function.

  3. Under Runtime, select Python 3.7.

Execution environment

The execution environment includes the runtime, the operating system, packages, and a library that invokes your function.

The Python runtime uses an execution environment based on Ubuntu 18.04 with Python version 3.7.1. See Cloud Functions Execution Environment for more information.

Source code structure

In order for Cloud Functions to find your function's definition, each runtime has certain structuring requirements for your source code. See Writing Cloud Functions for more information.

Specifying dependencies

There are two ways to specify dependencies for Cloud Functions written in Python: using the pip package manager's requirements.txt file or packaging local dependencies alongside your function. For more information, see Specifying dependencies in Python.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Functions Documentation