The Python Runtime

Cloud Functions supports the following Python runtimes:

  • Python 3.10 (recommended)
  • Python 3.9
  • Python 3.8
  • Python 3.7

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.


If you are using the Google Cloud CLI, you can specify the runtime by using the --runtime parameter. For example:

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

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


If you are using the console, you can select the runtime when you create and deploy a function. See the console quickstart for detailed instructions.

Execution environment

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

The Python 3.10 runtime uses an execution environment based on Ubuntu 22.04.

The Python 3.7, 3.8, and 3.9 runtimes use an execution environment based on Ubuntu 18.04.

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.

Dependency specification using the Pipfile/Pipfile.lock standard is currently not supported. Your project should not include these files.

Environment variables

The Python 3.8+ runtimes automatically set fewer environment variables than previous runtimes supported by Cloud Functions. For details, see Using Environment Variables.