Google Certified Professional Data Engineer

Sign Up Free or Log In to participate!

Google Cloud PubSub Python Samples

The links in the resources section need updating?

The Python PubSub Samples have been moved to:

https://github.com/googleapis/python-pubsub.git

from:

https://github.com/GoogleCloudPlatform/python-docs-samples.git

1 Answers

Hi Tim

I think Google are still maintaining the general Python samples repo, although the repo you have found also contains the Python client and samples specific to Pub/Sub.

Cheers

Lakshminarayan

Hello Tim, Code has moved and when we try to execute the Publishers.py, it throws error…would be helpful if instructions to execute the new code base is updated please.

Lakshminarayan

python3 schema.py playground-s-11-fc98dbcc create-topic LabTopic my-topic JSON Traceback (most recent call last): File "schema.py", line 479, in args.project_id, args.topic_id, args.schema_id, args.message_encoding File "schema.py", line 156, in create_topic_with_schema from google.api_core.exceptions import AlreadyExists, InvalidArgument ModuleNotFoundError: No module named ‘google’

Lakshminarayan

Well, did some googling and got it working with the new version of code

Lakshminarayan

Step 1: In the Cloud Console – sudo apt-get update

Lakshminarayan

Step 2: In the Cloud Console – sudo apt-get install virtualenv

Lakshminarayan

Step 3: In the Cloud Console – virtualenv -p python3 venv

Lakshminarayan

Step 4: In the Cloud Console – source venv/bin/activate

Lakshminarayan

Step 5: In the Cloud Console – venv/bin/pip install google-cloud-pubsub

Lakshminarayan

Step 6: In the Cloud Console – git clone https://github.com/googleapis/python-pubsub.git

Lakshminarayan

Step 7: In the Cloud Console – cd python-pubsub/samples/snippets

Lakshminarayan

Step 8: In the Cloud Console – export GLOBAL_CLOUD_PROJECT=

Lakshminarayan

Step 9: In the Cloud Console – python3 publisher.py $GLOBAL_CLOUD_PROJECT create

Lakshminarayan

Step 10: In the Cloud Console – python3 subscriber.py $GLOBAL_CLOUD_PROJECT create

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?