{"id":23,"library":"google-cloud-storage","title":"Google Cloud Python (google-cloud-storage / google-cloud-aiplatform)","description":"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.","status":"active","version":"google-cloud-storage: 2.x / google-cloud-aiplatform: 1.139.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python","tags":["gcp","google-cloud","storage","bigquery","vertex-ai","python","sdk"],"install":[{"cmd":"pip install google-cloud-storage","lang":"bash","label":"Cloud Storage"},{"cmd":"pip install google-cloud-bigquery","lang":"bash","label":"BigQuery"},{"cmd":"pip install google-cloud-aiplatform","lang":"bash","label":"Vertex AI / Gemini"}],"dependencies":[{"reason":"Credential management for all Google Cloud libraries. Installed automatically.","package":"google-auth","optional":false},{"reason":"Retry logic, pagination, transport. Installed automatically.","package":"google-api-core","optional":false}],"imports":[{"note":"Direct module import path works but is unconventional. Always use 'from google.cloud import storage'.","wrong":"import google.cloud.storage\nclient = google.cloud.storage.Client(project='my-project')","symbol":"google.cloud.storage (ADC)","correct":"from google.cloud import storage\n\n# ADC: reads GOOGLE_APPLICATION_CREDENTIALS env var or gcloud auth\nclient = storage.Client()\n\n# Explicit service account\nfrom google.oauth2 import service_account\ncredentials = service_account.Credentials.from_service_account_file('key.json')\nclient = storage.Client(credentials=credentials, project='my-project')"},{"note":"Vertex AI requires both project AND location at init. Missing location defaults to us-central1 but many models are only available in specific regions.","wrong":"from google.cloud import aiplatform\naiplatform.init(project='my-project')\n# Missing location= causes region errors for most Vertex endpoints","symbol":"google.cloud.aiplatform (Vertex AI)","correct":"import vertexai\nfrom vertexai.generative_models import GenerativeModel\n\nvertexai.init(project='my-project', location='us-central1')\nmodel = GenerativeModel('gemini-2.0-flash')\nresponse = model.generate_content('Hello')"}],"quickstart":{"code":"import os\nfrom google.cloud import storage\n\n# Auth via GOOGLE_APPLICATION_CREDENTIALS env var pointing to service account JSON\n# Or run 'gcloud auth application-default login' locally\n\nclient = storage.Client(project=os.environ['GOOGLE_CLOUD_PROJECT'])\n\n# List buckets\nbuckets = list(client.list_buckets())\nfor bucket in buckets:\n    print(bucket.name)\n\n# Upload a file\nbucket = client.bucket('my-bucket')\nblob = bucket.blob('hello.txt')\nblob.upload_from_string('Hello, GCS!')\nprint(f'Uploaded to gs://my-bucket/hello.txt')","lang":"python","description":"ADC credential chain: (1) GOOGLE_APPLICATION_CREDENTIALS JSON file, (2) gcloud application-default credentials, (3) GCE/Cloud Run metadata server."},"warnings":[{"fix":"pip install google-cloud-storage, google-cloud-bigquery, google-cloud-aiplatform, etc. individually.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json, or run 'gcloud auth application-default login' locally.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Workload Identity Federation on GCP. For other clouds, use Secret Manager or environment-injected credentials.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Always call vertexai.init(project='PROJECT_ID', location='REGION') with an explicit region before using GenerativeModel.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"pip install google-cloud-aiplatform>=1.38.0 for Gemini/GenerativeModel access.","message":"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.","severity":"gotcha","affected_versions":"< 1.38.0"},{"fix":"Install all google-cloud packages together in one pip command to let the resolver find compatible versions. Use pip check after installation.","message":"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.","severity":"gotcha","affected_versions":"all"},{"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')`.","message":"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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"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.","severity":"gotcha","affected_versions":"all"}],"env_vars":{"optional":[{"name":"GOOGLE_APPLICATION_CREDENTIALS","note":"Path to service account JSON key file. Most common auth method outside GCP. Without this (and without gcloud ADC), all API calls raise DefaultCredentialsError."},{"name":"GOOGLE_CLOUD_PROJECT","note":"Default GCP project ID. Many clients accept project= at construction but fall back to this env var."},{"name":"GOOGLE_CLOUD_QUOTA_PROJECT","note":"Project to bill API quota against. Separate from the project the resources live in."}],"required":[]},"last_verified":"2026-05-12T04:40:57.754Z","next_check":"2026-06-01T00:00:00.000Z","problems":[{"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`.","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.","error":"ModuleNotFoundError: No module named 'google.cloud.storage'"},{"fix":"Import `storage` from `google.cloud` and then instantiate `storage.Client()`: `from google.cloud import storage` followed by `client = storage.Client()`.","cause":"The `Client` class needs to be explicitly imported from the `google.cloud.storage` module, not accessed directly from the module itself.","error":"AttributeError: module 'google.cloud.storage' has no attribute 'Client'"},{"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.","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.","error":"403 Forbidden: Permission 'storage.buckets.get' denied"},{"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.","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.","error":"404 Not Found: Bucket not found"},{"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).","cause":"The application is attempting to access Cloud Storage without valid authentication credentials being configured or found by Application Default Credentials (ADC).","error":"No credentials provided"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.3,"mem_mb":24.3,"disk_size":"240.4M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.21,"mem_mb":21.9,"disk_size":"50.6M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.93,"mem_mb":23,"disk_size":"237M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.88,"mem_mb":20.7,"disk_size":"51M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.15,"mem_mb":26.3,"disk_size":"270.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.09,"mem_mb":24.4,"disk_size":"54.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.46,"mem_mb":25.1,"disk_size":"268M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.37,"mem_mb":23,"disk_size":"56M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.12,"mem_mb":26.5,"disk_size":"258.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.97,"mem_mb":24.1,"disk_size":"46.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.82,"mem_mb":25.1,"disk_size":"256M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.73,"mem_mb":23,"disk_size":"47M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.06,"mem_mb":27.1,"disk_size":"255.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.99,"mem_mb":25.3,"disk_size":"45.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.78,"mem_mb":25.9,"disk_size":"253M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.73,"mem_mb":24.2,"disk_size":"47M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.11,"mem_mb":23.9,"disk_size":"236.8M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.05,"mem_mb":21.8,"disk_size":"50.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":22.6,"disk_size":"234M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":20.6,"disk_size":"51M"}]},"quickstart_checks":{"last_tested":"2026-05-11","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}