[pubsub] 'module' object has no attribute 'Client'
See original GitHub issueI 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:
- Created 6 years ago
- Comments:20 (9 by maintainers)
Thanks @tseaver, reinstalling the packages (and downgrading google-cloud-pubsub to 0.27) did the trick. Apparently
pubsub.Client
was removed in 0.28I would double check that you are not being hosed by a pip / setuptools whack-a-mole bug due to namespace packages, recently fixed (again):