How to Install google-cloud-pubsub in Python

v2.37.0 General Purpose Python >=3.9 Apache 2.0

Google Cloud Pub/Sub API client library

Install pip install google-cloud-pubsub

What is google-cloud-pubsub?

Google Cloud Pub/Sub API client library

'Google Cloud Pub/Sub:' is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. You can leverage Cloud Pub/Sub’s flexibility to decouple systems and components hosted on Google Cloud Platform or elsewhere on the Internet. By building on the same technology Google uses, Cloud Pub / Sub is designed to provide “at least once” delivery at low latency with on-demand scalability to 1 million messages per second (and beyond).

Publisher applications can send messages to a `` and other applications can subscribe to that topic to receive the messages. By decoupling senders and receivers, Google Cloud Pub/Sub allows developers to communicate between independently written applications.

In order to use this library, you first need to go through the following steps:

Quick Start

Minimal example to get started with google-cloud-pubsub:

import google_cloud_pubsub

print(google_cloud_pubsub.__version__)

Installation

pip (standard)

pip install google-cloud-pubsub

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install google-cloud-pubsub

pip3

pip3 install google-cloud-pubsub

conda

conda install -c conda-forge google-cloud-pubsub

Poetry

poetry add google-cloud-pubsub

Dependencies

Installing google-cloud-pubsub will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import google_cloud_pubsub; print(google_cloud_pubsub.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing google-cloud-pubsub with pip.

ModuleNotFoundError: No module named 'google_cloud_pubsub'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install google-cloud-pubsub. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'google_cloud_pubsub' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install google-cloud-pubsub to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'google_cloud_pubsub'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show google-cloud-pubsub and upgrade with pip install --upgrade google-cloud-pubsub.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install google-cloud-pubsub. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user google-cloud-pubsub

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org google-cloud-pubsub

Recent Releases

VersionReleased
2.37.0 latest 2026-04-10
2.36.0 2026-03-12
2.35.0 2026-02-05
2.34.0 2025-12-16
2.33.0 2025-10-30

Full release history on PyPI →

Manage google-cloud-pubsub

Upgrade to latest version

pip install --upgrade google-cloud-pubsub

Install a specific version

pip install google-cloud-pubsub==2.37.0

Uninstall

pip uninstall google-cloud-pubsub

Check what is installed

pip show google-cloud-pubsub

Last updated: 2026-04-11 • Data from PyPI