2
votes

I've used pip (and pip3) to install google-api-python-client, all over the place, but whenever I try to issue

from google.cloud import bigquery

I get an

ImportError: No module named google.cloud" error.

sys.path contains the directory that pip reports google-api-python-client is installed in, although it's near the end of a long(ish) list of directories.

Edit:

I've also installed google-cloud. The error occurs with both libraries installed.

Edit2: the Location for both are: "/home/swood/.local/lib/python3.5/site-packages"

print(sys.path) returns: ['/mnt/pasnas00/dbdata/snowflakedata/lib', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/swood/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']

1
Can we see pip3 show google-api-python-client | grep Location and print(sys.path). Replace grep with findstr if you are using windows. - JacobIRR
i'd recommend using a virtualenv as well so you can be 100% sure of what is installed and where it comes any source of conflict between packages. - Willian Fuks

1 Answers

2
votes

That's because those are different libraries. You have installed the Google API Client and trying to import the Google Cloud one. For an overview of the differences you can refer to this documentation.

Install it with this instead:

pip install google-cloud

or with pip3 for Python3. If you still want to use the other Client you'll need to import it and build the BigQuery service with something like this:

from googleapiclient.discovery import build
...
service = build('bigquery', 'v2', credentials=credentials)