- 3.5.0 (latest)
- 3.4.1
- 3.3.1
- 3.2.0
- 3.1.1
- 3.0.0
- 2.19.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.1
- 2.1.0
- 2.0.0
- 1.44.0
- 1.43.0
- 1.42.3
- 1.41.1
- 1.40.0
- 1.39.0
- 1.38.0
- 1.37.1
- 1.36.2
- 1.35.1
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.2
- 1.30.0
- 1.29.0
- 1.28.1
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
Python Client for Google Cloud Storage
Google Cloud Storage is a managed service for storing unstructured data. Cloud Storageallows world-wide storage and retrieval of any amount of data at any time. You can useCloud Storage for a range of scenarios including serving website content, storing datafor archival and disaster recovery, or distributing large data objects to users via direct download.
A comprehensive list of changes in each version may be found in theCHANGELOG.
Certain control plane and long-running operations for Cloud Storage (including Folderand Managed Folder operations) are supported via theStorage Control Client.TheStorage Control API creates one space to perform metadata-specific, control plane,and long-running operations apart from the Storage API.
Read more about the client libraries for Cloud APIs, including the olderGoogle APIs Client Libraries, inClient Libraries Explained.
Quick Start
In order to use this library, you first need to go through the following steps.A step-by-step guide may also be found inGet Started with Client Libraries.
Installation
Install this library in a virtual environment usingvenv.venv is a tool thatcreates isolated Python environments. These isolated environments can have separateversions of Python packages, which allows you to isolate one project’s dependenciesfrom the dependencies of other projects.
Withvenv, it’s possible to install this library without needing systeminstall permissions, and without clashing with the installed systemdependencies.
Code samples and snippets
Code samples and snippets live in thesamples/ folder.
Supported Python Versions
Our client libraries are compatible with all currentactive andmaintenance versions ofPython.
Python >= 3.7
Unsupported Python Versions
Python <= 3.6
If you are using anend-of-lifeversion of Python, we recommend that you update as soon as possible to an actively supported version.
Mac/Linux
python3 -m venv <your-env>source <your-env>/bin/activatepip install google-cloud-storageWindows
py -m venv <your-env>.\<your-env>\Scripts\activatepip install google-cloud-storageTracing With OpenTelemetry
This is a PREVIEW FEATURE: Coverage and functionality are still in development and subject to change.
This library can be configured to useOpenTelemetry to generate traces on calls to Google Cloud Storage.For information on the benefits and utility of tracing, read theCloud Trace Overview.
To enable OpenTelemetry tracing in the Cloud Storage client, first install OpenTelemetry:
pip install google-cloud-storage[tracing]Set theENABLE_GCS_PYTHON_CLIENT_OTEL_TRACES environment variable to selectively opt-in tracing for the Cloud Storage client:
export ENABLE_GCS_PYTHON_CLIENT_OTEL_TRACES=TrueYou will also need to tell OpenTelemetry which exporter to use. An example to export traces to Google Cloud Trace can be found below.
# Install the Google Cloud Trace exporter and propagator, however you can use any exporter of your choice.pip install opentelemetry-exporter-gcp-trace opentelemetry-propagator-gcp# [Optional] Install the OpenTelemetry Requests Instrumentation to trace the underlying HTTP requests.pip install opentelemetry-instrumentation-requestsfrom opentelemetry import tracefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessorfrom opentelemetry.exporter.cloud_trace import CloudTraceSpanExportertracer_provider = TracerProvider()tracer_provider.add_span_processor(BatchSpanProcessor(CloudTraceSpanExporter()))trace.set_tracer_provider(tracer_provider)# Optional yet recommended to instrument the requests HTTP libraryfrom opentelemetry.instrumentation.requests import RequestsInstrumentorRequestsInstrumentor().instrument(tracer_provider=tracer_provider)In this example, tracing data will be published to theGoogle Cloud Trace console.Tracing is most effective when many libraries are instrumented to provide insight over the entire lifespan of a request.For a list of libraries that can be instrumented, refer to theOpenTelemetry Registry.
Next Steps
Read theGoogle Cloud Storage Product documentation to learnmore about the product and see How-to Guides.
Read theClient Library Documentation for Google Cloud Storage APIto see other available methods on the client.
View thisREADME to see the full list of CloudAPIs that we cover.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-05 UTC.