Hide
Python

Python starter projects

These step-by-step guides will show you how to get your first Python app deployed and running on Google Cloud Platform in just minutes. From there, you can pick and choose what you want to learn. We'll cover storing structured and binary data, authentication, logging, pub/sub events, deploying and scaling your app, and more. Start building and deploying on Google Cloud Platform with a free trial.

Hello World app logo

Make a Hello World app

Hello Python! Deploy a basic Python application by using Google App Engine Managed VMs. Your application can automatically scale to serve millions of requests.

Bookshelf app logo

Build the Bookshelf app

Learn how to use Google Cloud Platform services to build a full-featured, scalable application with Python. This tutorial demonstrates how to store data, authenticate users, monitor your application, and send messages between applications by using pub/sub events.

Client library

The Google Cloud Client Library for Python significantly reduces the boilerplate code you have to write. The library provides a high-level pythonic API that's easier to understand than using HTTP directly. It embraces python standards, works well with the standard library, and integrates better with your codebase. All this means you spend more time creating code that matters to you.

Install the Google Cloud Client Library or view it on GitHub

pip install gcloud==0.7.0

See some code examples

from gcloud import datastore


dataset = datastore.Client(dataset_id='my-project-id')

entity = datastore.Entity(key=dataset.key('Greeting'))
entity['message'] = 'Hello, world!'

dataset.put(entity)

query = dataset.query(kind='Greeting')
for result in query.fetch():
    print(result)
from gcloud import storage

gcs = storage.Client(project='your-project-id')
bucket = gcs.get_bucket('your-bucket-id')

blob = storage.Blob('example.txt', bucket=bucket)
blob.upload_from_string('Hello, world!')


print(blob.download_as_string())
from gcloud import pubsub

client = pubsub.Client(project='your-project-id')
topic = client.topic('your-topic-name')

topic.publish('Ping!')

subscription = topic.subscription('your-subscription-name')

messages = subcription.pull()

for ackid, message in messages:
    print message

subscription.acknowledge([ackid for ackid, _ in messages])