Search code examples
pythongoogle-bigquery

Bases must be type error when running "from google.cloud import bigquery" in jupyter notebook in GCP


I tried running the following:

from google.cloud import bigquery

But from some reason, I keep getting this "Bases must be types" error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-1035661e8528> in <module>
----> 1 from google.cloud import bigquery

/opt/conda/lib/python3.7/site-packages/google/cloud/bigquery/__init__.py in <module>
     33 __version__ = bigquery_version.__version__
     34 
---> 35 from google.cloud.bigquery.client import Client
     36 from google.cloud.bigquery.dataset import AccessEntry
     37 from google.cloud.bigquery.dataset import Dataset

/opt/conda/lib/python3.7/site-packages/google/cloud/bigquery/client.py in <module>
     58 
     59 import google.api_core.client_options
---> 60 import google.api_core.exceptions as core_exceptions
     61 from google.api_core.iam import Policy
     62 from google.api_core import page_iterator

/opt/conda/lib/python3.7/site-packages/google/api_core/exceptions.py in <module>
     27 import warnings
     28 
---> 29 from google.rpc import error_details_pb2
     30 
     31 try:

/opt/conda/lib/python3.7/site-packages/google/rpc/error_details_pb2.py in <module>
     18 # source: google/rpc/error_details.proto
     19 """Generated protocol buffer code."""
---> 20 from google.protobuf import descriptor as _descriptor
     21 from google.protobuf import descriptor_pool as _descriptor_pool
     22 from google.protobuf import message as _message

/opt/conda/lib/python3.7/site-packages/google/protobuf/descriptor.py in <module>
     38 import warnings
     39 
---> 40 from google.protobuf.internal import api_implementation
     41 
     42 _USE_C_DESCRIPTORS = False

/opt/conda/lib/python3.7/site-packages/google/protobuf/internal/api_implementation.py in <module>
    102   try:
    103     # pylint: disable=g-import-not-at-top
--> 104     from google.protobuf.pyext import _message
    105     sys.modules['google3.net.proto2.python.internal.cpp._message'] = _message
    106     _c_module = _message

TypeError: bases must be types

I'm not sure what I did wrong. Maybe I install or uninstalled a package somewhere. But now I can't get this simple command to work. Any help would be greatly appreciated.


Solution

  • Marking this as an answer for better visibility, as this resolved the question: pip installing protobuff v3.20.1 as @runner16 mentioned

    pip install protobuf==3.20.1