Google Cloud Storage allows you to store data on
Google infrastructure with very high reliability, performance and
availability, and can be used to distribute large data objects to users
via direct download.
Install this library in a virtualenv using pip. virtualenv is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.
With virtualenv, it’s possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.
Supported Python Versions
Python >= 3.5
Deprecated Python Versions
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
You need to create a Google Cloud Storage bucket to use this client library.
Follow along with the official Google Cloud Storage documentation to learn
how to create a bucket.
from google.cloud import storage
client = storage.Client()
# https://console.cloud.google.com/storage/browser/[bucket-id]/
bucket = client.get_bucket('bucket-id-here')
# Then do other things...
blob = bucket.get_blob('remote/path/to/file.txt')
print(blob.download_as_string())
blob.upload_from_string('New contents!')
blob2 = bucket.blob('remote/path/storage.txt')
blob2.upload_from_filename(filename='/local/path.txt')
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-01 UTC."],[],[],null,["Version 1.21.0keyboard_arrow_down\n\n- [3.3.1 (latest)](/python/docs/reference/storage/latest)\n- [3.3.0](/python/docs/reference/storage/3.3.0)\n- [3.2.0](/python/docs/reference/storage/3.2.0)\n- [3.1.1](/python/docs/reference/storage/3.1.1)\n- [3.0.0](/python/docs/reference/storage/3.0.0)\n- [2.19.0](/python/docs/reference/storage/2.19.0)\n- [2.17.0](/python/docs/reference/storage/2.17.0)\n- [2.16.0](/python/docs/reference/storage/2.16.0)\n- [2.15.0](/python/docs/reference/storage/2.15.0)\n- [2.14.0](/python/docs/reference/storage/2.14.0)\n- [2.13.0](/python/docs/reference/storage/2.13.0)\n- [2.12.0](/python/docs/reference/storage/2.12.0)\n- [2.11.0](/python/docs/reference/storage/2.11.0)\n- [2.10.0](/python/docs/reference/storage/2.10.0)\n- [2.9.0](/python/docs/reference/storage/2.9.0)\n- [2.8.0](/python/docs/reference/storage/2.8.0)\n- [2.7.0](/python/docs/reference/storage/2.7.0)\n- [2.6.0](/python/docs/reference/storage/2.6.0)\n- [2.5.0](/python/docs/reference/storage/2.5.0)\n- [2.4.0](/python/docs/reference/storage/2.4.0)\n- [2.3.0](/python/docs/reference/storage/2.3.0)\n- [2.2.1](/python/docs/reference/storage/2.2.1)\n- [2.1.0](/python/docs/reference/storage/2.1.0)\n- [2.0.0](/python/docs/reference/storage/2.0.0)\n- [1.44.0](/python/docs/reference/storage/1.44.0)\n- [1.43.0](/python/docs/reference/storage/1.43.0)\n- [1.42.3](/python/docs/reference/storage/1.42.3)\n- [1.41.1](/python/docs/reference/storage/1.41.1)\n- [1.40.0](/python/docs/reference/storage/1.40.0)\n- [1.39.0](/python/docs/reference/storage/1.39.0)\n- [1.38.0](/python/docs/reference/storage/1.38.0)\n- [1.37.1](/python/docs/reference/storage/1.37.1)\n- [1.36.2](/python/docs/reference/storage/1.36.2)\n- [1.35.1](/python/docs/reference/storage/1.35.1)\n- [1.34.0](/python/docs/reference/storage/1.34.0)\n- [1.33.0](/python/docs/reference/storage/1.33.0)\n- [1.32.0](/python/docs/reference/storage/1.32.0)\n- [1.31.2](/python/docs/reference/storage/1.31.2)\n- [1.30.0](/python/docs/reference/storage/1.30.0)\n- [1.29.0](/python/docs/reference/storage/1.29.0)\n- [1.28.1](/python/docs/reference/storage/1.28.1)\n- [1.27.0](/python/docs/reference/storage/1.27.0)\n- [1.26.0](/python/docs/reference/storage/1.26.0)\n- [1.25.0](/python/docs/reference/storage/1.25.0)\n- [1.24.1](/python/docs/reference/storage/1.24.1)\n- [1.23.0](/python/docs/reference/storage/1.23.0)\n- [1.22.0](/python/docs/reference/storage/1.22.0)\n- [1.21.0](/python/docs/reference/storage/1.21.0)\n- [1.20.0](/python/docs/reference/storage/1.20.0)\n- [1.19.0](/python/docs/reference/storage/1.19.0)\n- [1.18.0](/python/docs/reference/storage/1.18.0)\n- [1.17.0](/python/docs/reference/storage/1.17.0) \n\nPython Client for Google Cloud Storage\n\n[](https://github.com/googleapis/google-cloud-python/blob/master/README.rst#general-availability) [](https://pypi.org/project/google-cloud-storage) [](https://pypi.org/project/google-cloud-storage)\n\n[Google Cloud Storage](https://cloud.google.com/storage/docs) allows you to store data on\nGoogle infrastructure with very high reliability, performance and\navailability, and can be used to distribute large data objects to users\nvia direct download.\n\n- [Client Library Documentation](https://googleapis.dev/python/storage/latest)\n\n- [Storage API docs](https://cloud.google.com/storage/docs/json_api/v1)\n\nQuick Start\n\nIn order to use this library, you first need to go through the following steps:\n\n1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)\n\n2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)\n\n3. [Enable the Google Cloud Storage API.](https://cloud.google.com/storage)\n\n4. [Setup Authentication.](https://googleapis.dev/python/google-api-core/latest/auth.html)\n\nInstallation\n\nInstall this library in a [virtualenv](https://virtualenv.pypa.io/en/latest/) using pip. [virtualenv](https://virtualenv.pypa.io/en/latest/) is a tool to\ncreate isolated Python environments. The basic problem it addresses is one of\ndependencies and versions, and indirectly permissions.\n\nWith [virtualenv](https://virtualenv.pypa.io/en/latest/), it's possible to install this library without needing system\ninstall permissions, and without clashing with the installed system\ndependencies.\n\nSupported Python Versions\n\nPython \\\u003e= 3.5\n\nDeprecated Python Versions\n\nPython == 2.7. Python 2.7 support will be removed on January 1, 2020.\n\nMac/Linux \n\n pip install virtualenv\n virtualenv \u003cyour-env\u003e\n source \u003cyour-env\u003e/bin/activate\n \u003cyour-env\u003e/bin/pip install google-cloud-storage\n\nWindows \n\n pip install virtualenv\n virtualenv \u003cyour-env\u003e\n \u003cyour-env\u003e\\Scripts\\activate\n \u003cyour-env\u003e\\Scripts\\pip.exe install google-cloud-storage\n\nExample Usage\n\nYou need to create a Google Cloud Storage bucket to use this client library.\nFollow along with the [official Google Cloud Storage documentation](https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets) to learn\nhow to create a bucket. \n\n from google.cloud import https://cloud.google.com/python/docs/reference/storage/latest/\n client = https://cloud.google.com/python/docs/reference/storage/latest/.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.client.Client.html()\n # https://console.cloud.google.com/storage/browser/[bucket-id]/\n bucket = client.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.client.Client.html#google_cloud_storage_client_Client_get_bucket('bucket-id-here')\n # Then do other things...\n blob = bucket.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.bucket.Bucket.html#google_cloud_storage_bucket_Bucket_get_blob('remote/path/to/file.txt')\n print(blob.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.blob.Blob.html#google_cloud_storage_blob_Blob_download_as_string())\n blob.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.blob.Blob.html#google_cloud_storage_blob_Blob_upload_from_string('New contents!')\n blob2 = bucket.blob('remote/path/storage.txt')\n blob2.https://cloud.google.com/python/docs/reference/storage/latest/google.cloud.storage.blob.Blob.html#google_cloud_storage_blob_Blob_upload_from_filename(filename='/local/path.txt')"]]