ImportError: cannot import name pubsub_v1
Question:
I need to import Pubsub_v1 and bigquery from google.cloud module. I have installed it and pip freeze shows below :
gapic-google-cloud-pubsub-v1==0.15.4
google-cloud-bigquery==0.26.0
google-cloud-pubsub==0.27.0
proto-google-cloud-pubsub-v1==0.15.4
In my python script, i am importing the modules as below:
import os
from google.cloud import pubsub_v1
import time
import json
from google.cloud import bigquery
The script is throwing error as :
ImportError: cannot import name pubsub_v1
If i run $sudo pip install –upgrade google-cloud-pubsub then It is able to import pubsub but failing to import Bigquery. I need both modules. Can anybody please help ?
Answers:
Upgraded the other google.cloud modules using
$sudo pip install --upgrade google-cloud-bigquery
$sudo pip install --upgrade google-cloud-storage
$sudo pip install --upgrade google-cloud-logging
It resolves the issue.
I had the same problem, it happened to me because I installed google-cloud-pubsub before google-cloud so here is my advise :
sudo pip uninstall google-cloud-pubsub
sudo pip uninstall google-cloud
sudo pip install google-cloud
sudo pip install google-cloud-pubsub
$sudo pip install googleapis-common-protos
It resolves the issue for me!
These were helpful to resolve the issue for python 3.x version: (I assumed the pip3 has been installed)
sudo pip3 install google-cloud-bigquery
sudo pip3 install google-cloud-pubsub
sudo apt-get upgrade
I had the same issue while trying the pubsub
python library. I followed the below steps to resolve the issue:
Upgrade the pip library:
pip install --upgrade pip setuptools
pip3 install --ignore-installed PyYAML
pip3 install google-cloud-pubsub
just this one solved my issue
the others were not useful
sudo pip3 install google-cloud-pubsub
I need to import Pubsub_v1 and bigquery from google.cloud module. I have installed it and pip freeze shows below :
gapic-google-cloud-pubsub-v1==0.15.4
google-cloud-bigquery==0.26.0
google-cloud-pubsub==0.27.0
proto-google-cloud-pubsub-v1==0.15.4
In my python script, i am importing the modules as below:
import os
from google.cloud import pubsub_v1
import time
import json
from google.cloud import bigquery
The script is throwing error as :
ImportError: cannot import name pubsub_v1
If i run $sudo pip install –upgrade google-cloud-pubsub then It is able to import pubsub but failing to import Bigquery. I need both modules. Can anybody please help ?
Upgraded the other google.cloud modules using
$sudo pip install --upgrade google-cloud-bigquery
$sudo pip install --upgrade google-cloud-storage
$sudo pip install --upgrade google-cloud-logging
It resolves the issue.
I had the same problem, it happened to me because I installed google-cloud-pubsub before google-cloud so here is my advise :
sudo pip uninstall google-cloud-pubsub
sudo pip uninstall google-cloud
sudo pip install google-cloud
sudo pip install google-cloud-pubsub
$sudo pip install googleapis-common-protos
It resolves the issue for me!
These were helpful to resolve the issue for python 3.x version: (I assumed the pip3 has been installed)
sudo pip3 install google-cloud-bigquery
sudo pip3 install google-cloud-pubsub
sudo apt-get upgrade
I had the same issue while trying the pubsub
python library. I followed the below steps to resolve the issue:
Upgrade the pip library:
pip install --upgrade pip setuptools
pip3 install --ignore-installed PyYAML
pip3 install google-cloud-pubsub
just this one solved my issue
the others were not useful
sudo pip3 install google-cloud-pubsub