Google Cloud Python (google-cloud-storage / google-cloud-aiplatform)
raw JSON → google-cloud-storage: 2.x / google-cloud-aiplatform: 1.139.0 verified Tue May 12 auth: no python install: verified quickstart: stale
Google Cloud's Python client libraries are split into per-service packages — there is no single 'google-cloud-python' package. Install only what you need: google-cloud-storage, google-cloud-bigquery, google-cloud-aiplatform, etc. Auth uses Application Default Credentials (ADC). Service account JSON is the most common auth method outside GCP. All packages share google-auth as the credential layer.
pip install google-cloud-storage Common errors
error ModuleNotFoundError: No module named 'google.cloud.storage' ↓
cause The 'google-cloud-storage' Python package is not installed in the environment where the code is being run, or there is a Python version mismatch.
fix
Install the package using pip:
pip install google-cloud-storage. If using a specific Python version, try python3 -m pip install google-cloud-storage. error AttributeError: module 'google.cloud.storage' has no attribute 'Client' ↓
cause The `Client` class needs to be explicitly imported from the `google.cloud.storage` module, not accessed directly from the module itself.
fix
Import
storage from google.cloud and then instantiate storage.Client(): from google.cloud import storage followed by client = storage.Client(). error 403 Forbidden: Permission 'storage.buckets.get' denied ↓
cause The service account or user credentials used by the application lack the necessary Identity and Access Management (IAM) permissions to perform the requested operation on the Google Cloud Storage bucket or object.
fix
Grant the appropriate IAM role (e.g., 'Storage Object Viewer', 'Storage Object Admin', or 'Storage Admin') to the service account or user. Ensure the role is applied at the correct resource level (project, bucket, or object) in the Google Cloud Console.
error 404 Not Found: Bucket not found ↓
cause The specified bucket name is incorrect, contains typos (including invisible characters like spaces), or the bucket does not exist in the Google Cloud project associated with the credentials.
fix
Verify the exact bucket name for correctness, check for any leading/trailing spaces or other typos, and confirm that the bucket exists in the Google Cloud project being used.
error No credentials provided ↓
cause The application is attempting to access Cloud Storage without valid authentication credentials being configured or found by Application Default Credentials (ADC).
fix
For local development, run
gcloud auth application-default login to set up ADC. For deployment, ensure the GOOGLE_APPLICATION_CREDENTIALS environment variable points to a valid service account key JSON file, or that the environment implicitly provides credentials (e.g., on a Google Cloud VM). Warnings
gotcha There is no single 'google-cloud-python' package on PyPI. It must be installed per-service. 'pip install google-cloud-python' installs nothing useful — it's a meta-package stub that does not bring in any service clients. ↓
fix pip install google-cloud-storage, google-cloud-bigquery, google-cloud-aiplatform, etc. individually.
gotcha DefaultCredentialsError is raised when no ADC credentials are found. Common in CI/CD when GOOGLE_APPLICATION_CREDENTIALS is not set and gcloud is not authenticated. On GCP services (Cloud Run, GKE, etc.) the metadata server provides credentials automatically. ↓
fix Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json, or run 'gcloud auth application-default login' locally.
gotcha Service account JSON key files contain private keys — committing them to source control is a critical security issue. Google's Secret Manager or Workload Identity Federation are the recommended alternatives for production. ↓
fix Use Workload Identity Federation on GCP. For other clouds, use Secret Manager or environment-injected credentials.
gotcha Vertex AI (google-cloud-aiplatform) requires vertexai.init(project=..., location=...) before any model calls. Missing location= silently defaults to us-central1 — models not available in that region return 404 or permission errors. ↓
fix Always call vertexai.init(project='PROJECT_ID', location='REGION') with an explicit region before using GenerativeModel.
gotcha google-cloud-aiplatform ships weekly. The Vertex AI generative models API (GenerativeModel, generate_content) was added around v1.38 — older pinned versions don't have it and raise ImportError. ↓
fix pip install google-cloud-aiplatform>=1.38.0 for Gemini/GenerativeModel access.
gotcha google-auth, google-api-core, and protobuf version conflicts are extremely common when multiple google-cloud packages are installed. pip may silently downgrade shared dependencies, breaking other packages. ↓
fix Install all google-cloud packages together in one pip command to let the resolver find compatible versions. Use pip check after installation.
gotcha KeyError: 'GOOGLE_CLOUD_PROJECT' is raised when the GOOGLE_CLOUD_PROJECT environment variable is not set. Many Google Cloud client libraries or applications require an explicit project ID for billing and resource management, which is often sourced from this environment variable if not provided directly in code. ↓
fix Set the GOOGLE_CLOUD_PROJECT environment variable to your project ID, or explicitly pass the project ID to the client constructor, e.g., `storage.Client(project='your-project-id')`.
gotcha A KeyError: 'GOOGLE_CLOUD_PROJECT' occurs when a client (e.g., storage.Client, bigquery.Client) is explicitly initialized with project=os.environ['GOOGLE_CLOUD_PROJECT'] but the environment variable is not set. ↓
fix Set the GOOGLE_CLOUD_PROJECT environment variable, or pass the project ID directly to the client constructor (e.g., storage.Client(project='your-project-id')). Ensure the environment variable is available in the execution environment.
Install
pip install google-cloud-bigquery pip install google-cloud-aiplatform Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) google-cloud-aiplatform - - 1.30s 240.4M
3.10 alpine (musl) google-cloud-bigquery - - - -
3.10 alpine (musl) google-cloud-storage - - 1.21s 50.6M
3.10 slim (glibc) google-cloud-aiplatform - - 0.93s 237M
3.10 slim (glibc) google-cloud-bigquery - - - -
3.10 slim (glibc) google-cloud-storage - - 0.88s 51M
3.11 alpine (musl) google-cloud-aiplatform - - 2.15s 270.7M
3.11 alpine (musl) google-cloud-bigquery - - - -
3.11 alpine (musl) google-cloud-storage - - 2.09s 54.8M
3.11 slim (glibc) google-cloud-aiplatform - - 1.46s 268M
3.11 slim (glibc) google-cloud-bigquery - - - -
3.11 slim (glibc) google-cloud-storage - - 1.37s 56M
3.12 alpine (musl) google-cloud-aiplatform - - 2.12s 258.5M
3.12 alpine (musl) google-cloud-bigquery - - - -
3.12 alpine (musl) google-cloud-storage - - 1.97s 46.3M
3.12 slim (glibc) google-cloud-aiplatform - - 1.82s 256M
3.12 slim (glibc) google-cloud-bigquery - - - -
3.12 slim (glibc) google-cloud-storage - - 1.73s 47M
3.13 alpine (musl) google-cloud-aiplatform - - 2.06s 255.7M
3.13 alpine (musl) google-cloud-bigquery - - - -
3.13 alpine (musl) google-cloud-storage - - 1.99s 45.8M
3.13 slim (glibc) google-cloud-aiplatform - - 1.78s 253M
3.13 slim (glibc) google-cloud-bigquery - - - -
3.13 slim (glibc) google-cloud-storage - - 1.73s 47M
3.9 alpine (musl) google-cloud-aiplatform - - 1.11s 236.8M
3.9 alpine (musl) google-cloud-bigquery - - - -
3.9 alpine (musl) google-cloud-storage - - 1.05s 50.6M
3.9 slim (glibc) google-cloud-aiplatform - - 0.99s 234M
3.9 slim (glibc) google-cloud-bigquery - - - -
3.9 slim (glibc) google-cloud-storage - - 0.99s 51M
Imports
- google.cloud.storage (ADC) wrong
import google.cloud.storage client = google.cloud.storage.Client(project='my-project')correctfrom google.cloud import storage # ADC: reads GOOGLE_APPLICATION_CREDENTIALS env var or gcloud auth client = storage.Client() # Explicit service account from google.oauth2 import service_account credentials = service_account.Credentials.from_service_account_file('key.json') client = storage.Client(credentials=credentials, project='my-project') - google.cloud.aiplatform (Vertex AI) wrong
from google.cloud import aiplatform aiplatform.init(project='my-project') # Missing location= causes region errors for most Vertex endpointscorrectimport vertexai from vertexai.generative_models import GenerativeModel vertexai.init(project='my-project', location='us-central1') model = GenerativeModel('gemini-2.0-flash') response = model.generate_content('Hello')
Quickstart stale last tested: 2026-05-11
import os
from google.cloud import storage
# Auth via GOOGLE_APPLICATION_CREDENTIALS env var pointing to service account JSON
# Or run 'gcloud auth application-default login' locally
client = storage.Client(project=os.environ['GOOGLE_CLOUD_PROJECT'])
# List buckets
buckets = list(client.list_buckets())
for bucket in buckets:
print(bucket.name)
# Upload a file
bucket = client.bucket('my-bucket')
blob = bucket.blob('hello.txt')
blob.upload_from_string('Hello, GCS!')
print(f'Uploaded to gs://my-bucket/hello.txt')