How Do You Troubleshoot the Message “ImportError: cannot import name ‘pubsub_v1′”?

Problem scenario
From the Python command prompt or when running a Python program, you receive this message "ImportError: cannot import name 'pubsub_v1'". What should you do?

Solution
Possible Solution #1
Try to run the program as sudo: sudo python nameOfProg.py

Possible Solution #2
Prerequisite
This assumes that pip has been installed. If you need assistance see this posting "How Do You Install pip?".

Procedure
Try this with or without sudo (depending on whether or not you are using "sudo" to run the Python program):

sudo pip install google-cloud-pubsub
# You may want to omit the "sudo" in the above command.

Possible Solution #3
Prerequisite
This assumes that pip has been installed. If you need assistance see this posting "How Do You Install pip?".

sudo pip uninstall google-cloud-pubsub
sudo pip install google-cloud-pubsub

# You may or may not want to omit the "sudo" in the above commands.

Leave a comment

Your email address will not be published. Required fields are marked *