Google Cloud Meta-Package for Python

0.34.0 · abandoned · verified Thu Apr 09

The `google-cloud` Python package was historically a meta-package designed to install all client libraries for Google Cloud services. However, it was deprecated in June 2018 and marked as inactive/archived. Users are strongly advised to install individual, product-specific client libraries (e.g., `google-cloud-storage`) rather than this meta-package. Its last released version is 0.34.0, from July 2018.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to list Google Cloud Storage buckets using the `google-cloud-storage` client library. It relies on Application Default Credentials for authentication, which can be set up via the `gcloud CLI` or by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.

import os
from google.cloud import storage

# Ensure GOOGLE_APPLICATION_CREDENTIALS environment variable is set
# or gcloud is configured for Application Default Credentials.
# For example: export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json"

try:
    # Instantiates a client for Google Cloud Storage
    storage_client = storage.Client()

    # List all buckets in the project
    buckets = list(storage_client.list_buckets())
    if buckets:
        print("Buckets:")
        for bucket in buckets:
            print(f"  - {bucket.name}")
    else:
        print("No buckets found in the project.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure you have authenticated properly (e.g., 'gcloud auth application-default login')")
    print("and have the necessary permissions for the Google Cloud project.")

view raw JSON →