我正在尝试从google.cloud导入bigquery,但是失败了,因为缺少依赖项。我正在使用Python 3.7.1。
这是我遇到的错误:
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import bigquery
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
from google.cloud.bigquery.client import Client
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery/client.py", line 53, in <module>
from google.cloud.bigquery.dataset import Dataset
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery/dataset.py", line 24, in <module>
from google.cloud.bigquery.model import ModelReference
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery/model.py", line 27, in <module>
from google.cloud.bigquery_v2 import types
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery_v2/__init__.py", line 23, in <module>
from google.cloud.bigquery_v2 import types
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery_v2/types.py", line 23, in <module>
from google.cloud.bigquery_v2.proto import model_pb2
File "/anaconda3/lib/python3.7/site-packages/google/cloud/bigquery_v2/proto/model_pb2.py", line 28, in <module>
from google.api import client_pb2 as google_dot_api_dot_client__pb2
ImportError: cannot import name 'client_pb2' from 'google.api' (/anaconda3/lib/python3.7/site-packages/google/api/__init__.py)
我尝试了升级,卸载和重新安装“ google-cloud-bigquery”和“ google-api-python-client”库,但是此错误继续发生。
我不确定如何解决此错误或如何进一步调试它。我以为它可能是我的软件包版本,但是我无法在其他计算机上复制此问题。可能是由于我的Python版本导致的,还是因为它是通过Anaconda安装的?
编辑: https://github.com/googleapis/google-cloud-python/issues/8674
解决方案到位-升级googleapis-common-protos
答案 0 :(得分:0)
正如您在帖子中提到的,解决方案是使用以下方法更新模块googleapis-common-protos
:
pip install --upgrade googleapis-common-protos
Common Protos是整个Google API生态系统中常见的依赖项,并且可以用作BigQuery的其他依赖项。