question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[pubsub] 'module' object has no attribute 'Client'

See original GitHub issue

I have been using pubsub for a while but after updating it, I am getting AttributeError: 'module' object has no attribute 'Client'

I am following this example from the official docs:

macOS 10.12.5 (16F73)

Name: google-cloud-pubsub Version: 0.25.0 Summary: Python Client for Google Cloud Pub/Sub Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python Author: Google Cloud Platform Author-email: jjg+google-cloud-python@google.com License: Apache 2.0 Requires: grpcio, gapic-google-cloud-pubsub-v1, google-cloud-core

Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import pubsub
>>> pubsub.Client()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Client'

ubuntu 16.04.2 (4.4.0-1013-aws)

Name: google-cloud-pubsub Version: 0.25.0 Summary: Python Client for Google Cloud Pub/Sub Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python Author: Google Cloud Platform Author-email: jjg+google-cloud-python@google.com License: Apache 2.0 Location: /usr/local/lib/python2.7/dist-packages Requires: google-cloud-core, gapic-google-cloud-pubsub-v1, grpcio

Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import pubsub
>>> pubsub.Client()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Client'

I have already uninstalled and reinstalled it (and the entire dependency tree) many times.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
fcaldascommented, Aug 31, 2017

Thanks @tseaver, reinstalling the packages (and downgrading google-cloud-pubsub to 0.27) did the trick. Apparently pubsub.Client was removed in 0.28

2reactions
tseavercommented, Aug 31, 2017

I would double check that you are not being hosed by a pip / setuptools whack-a-mole bug due to namespace packages, recently fixed (again):

$ pip install -U setuptools pip
Read more comments on GitHub >

github_iconTop Results From Across the Web

'module' object has no attribute 'Client' when running python in ...
The pubsub.Client class exists until the 0.27.0 version of the pubsub python package. So I just created a virtual environment and installed ...
Read more >
google-cloud-pubsub - PyPI
Google Cloud Pub / Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications.
Read more >
Publish and receive messages in Pub/Sub by using a client ...
This page shows you how to get started publishing messages with Pub/Sub using client libraries. Pub/Sub offers a high-level and a low-level auto-generated ......
Read more >
AttributeError: 'Credentials' object has no attribute 'authorize'
I am getting following error while deploying the app. I have changed peoject Id in config file. ERROR: (gcloud.app.deploy) Error Response: [9]
Read more >
pubsub - Go Packages
Once client code has processed the message, it must call Message. ... properties (other than data) are written to // a JSON object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found