1

I have been trying to run the code on this page which describes how to authenticate before using the pandas_gbq.read_gbq function:

import pandas_gbq
import pydata_google_auth

SCOPES = [
    'https://www.googleapis.com/auth/cloud-platform',
    'https://www.googleapis.com/auth/drive',
]

credentials = pydata_google_auth.get_user_credentials(
    SCOPES,
    # Set auth_local_webserver to True to have a slightly more convienient
    # authorization flow. Note, this doesn't work if you're running from a
    # notebook on a remote sever, such as over SSH or with Google Colab.
    auth_local_webserver=True,)


df = pandas_gbq.read_gbq(
    "SELECT my_col FROM `my_dataset.my_table`",
    project_id='YOUR-PROJECT-ID',
    credentials=credentials,)

I am getting the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/pandas_gbq/gbq.py in _test_google_api_imports()
     94 
---> 95     try:
     96         from google.cloud import bigquery  # noqa

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery/__init__.py in <module>
     34 
---> 35 from google.cloud.bigquery.client import Client
     36 from google.cloud.bigquery.dataset import AccessEntry

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery/client.py in <module>
     52 from google.cloud.bigquery import _pandas_helpers
---> 53 from google.cloud.bigquery.dataset import Dataset
     54 from google.cloud.bigquery.dataset import DatasetListItem

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py in <module>
     23 from google.cloud.bigquery import _helpers
---> 24 from google.cloud.bigquery.model import ModelReference
     25 from google.cloud.bigquery.routine import RoutineReference

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery/model.py in <module>
     26 from google.cloud.bigquery import _helpers
---> 27 from google.cloud.bigquery_v2 import types
     28 

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery_v2/__init__.py in <module>
     22 
---> 23 from google.cloud.bigquery_v2 import types
     24 from google.cloud.bigquery_v2.gapic import enums

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery_v2/types.py in <module>
     22 
---> 23 from google.cloud.bigquery_v2.proto import model_pb2
     24 from google.cloud.bigquery_v2.proto import model_reference_pb2

/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/bigquery_v2/proto/model_pb2.py in <module>
     27 from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
---> 28 from google.api import client_pb2 as google_dot_api_dot_client__pb2
     29 

ImportError: cannot import name 'client_pb2' from 'google.api' (/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/api/__init__.py)

I have tried uninstalling and reinstalling using the following command line code without any luck:

pip install pandas-gbq -U

This same code seems to work without any issue on my PC with Anaconda installed. However, the code does not run on my mac. Both computers have python 3.7 installed. I installed python 3 on my mac via homebrew, and I do not have Anaconda installed on that computer.

1 Answer 1

0

I'm facing the same problem. but solve it by installing using conda:

conda install pandas-gbq --channel conda-forge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.