Install & Compatibility
Where this runs
tested against v1.24.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 1.804s · 82.7MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.5s · import 1.286s · 69MB
75MB installed
● package 75MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CloudFunctionsServiceClient
✓ from google.cloud.functions import CloudFunctionsServiceClient
✗ from google.cloud.functions_v2 import CloudFunctionsServiceClient
This quickstart demonstrates how to write a simple HTTP-triggered Google Cloud Function using the `functions-framework` library, which is the standard for defining and running Python Cloud Functions. To deploy, save the code as `main.py` and use the `gcloud functions deploy` command. For local testing, install `functions-framework` and run it against your function. [4, 8, 11]
import functions_framework
import os
@functions_framework.http
def hello_http(request):
"""HTTP Cloud Function that responds to HTTP requests.
Args:
request (flask.Request): The request object.
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`.
"""
request_json = request.get_json(silent=True)
request_args = request.args
# Example of accessing an environment variable set during deployment
target_name = os.environ.get('FUNCTION_TARGET_NAME', 'World')
name = target_name
if request_json and 'name' in request_json:
name = request_json['name']
elif request_args and 'name' in request_args:
name = request_args['name']
return f'Hello {name}!'
# To deploy this function (save as main.py):
# gcloud functions deploy hello-http --gen2 --runtime=python312 \
# --region=us-central1 --source=. --entry-point=hello_http --trigger-http \
# --set-env-vars=FUNCTION_TARGET_NAME=Pythonista
# To test locally after `pip install functions-framework`:
# functions-framework --target hello_http --debug
# Then send a request to http://localhost:8080/
Debug
Known issues
breakingMigration from Cloud Functions 1st generation to 2nd generation (now often referred to as 'Cloud Run functions') involves significant architectural changes. Direct redeployment of a 1st Gen function as 2nd Gen can break existing triggers due to the shift from native triggers to Eventarc. [14, 21, 29]fixReview the migration guide for 1st to 2nd Gen functions. This involves updating function signatures, trigger definitions (now Eventarc), and potentially `gcloud` deployment commands. Plan for phased rollout or new deployments. [14, 21]
affects: All versions when migrating between generations
breakingPython versions older than 3.9 are no longer supported. Deploying functions with unsupported Python runtimes will fail. [3, 19]fixEnsure your local development environment and deployed Cloud Function runtimes use Python 3.9 or higher. Update your `runtime` specification in `gcloud functions deploy` if necessary (e.g., `--runtime=python312`). [3, 19]
affects: < 1.0.0
gotchaAuthentication for HTTP-triggered Cloud Functions, especially when invoked programmatically, requires proper IAM permissions (`roles/cloudfunctions.invoker`) for the calling identity and often the use of an Identity Token (ID Token), not just an OAuth Access Token. Unauthenticated invocations must be explicitly enabled during deployment. [15, 16, 20, 26]fixGrant the `Cloud Functions Invoker` role to the service account or user invoking the function. For programmatic invocation, use `google.oauth2.id_token.fetch_id_token` to generate an ID token for the target function's URL and include it in the `Authorization: Bearer` header. [16, 20]
affects: All versions
gotchaPython dependencies for Cloud Functions are exclusively managed via a `requirements.txt` file in the root of your function's source directory. Tools like `Pipfile`/`Pipfile.lock` are not supported. For private dependencies or local packages, specific bundling or Artifact Registry configurations are required. The `functions-framework` library should be explicitly listed in `requirements.txt`. [1, 6, 8]fixAlways use `requirements.txt` for your function's dependencies. If using private packages, refer to Google Cloud documentation for integrating with Artifact Registry or packaging local dependencies. Ensure `functions-framework` is listed. [1, 2, 8]
affects: All versions
gotchaCloud Functions (2nd gen) are now referred to as 'Cloud Run functions' due to their underlying infrastructure being Cloud Run. While the `google-cloud-functions` client library can manage both generations, understanding this naming convention and the benefits of 2nd gen (concurrency, longer timeouts, Eventarc integration) is crucial. [12, 14, 29]fixFamiliarize yourself with the differences between 1st and 2nd generation functions and the features inherited from Cloud Run. When deploying 2nd Gen functions, consider using the `--gen2` flag with `gcloud functions deploy` or directly leveraging Cloud Run deployment commands for finer control. [12, 14, 29]
affects: All versions (conceptual shift)
Upgrade
Version history
1.24.0latest on PyPI · released Jun 22, 2026
Audit
Dependencies
functions-frameworkrequiredEssential for writing and locally testing Python Google Cloud Functions, and should be included in your function's `requirements.txt`. [4, 6, 8, 11]