【问题标题】:google cloud bigquery import failing because "ImportError: cannot import name 'client_pb2' from 'google.api'"谷歌云 bigquery 导入失败,因为“ImportError: cannot import name 'client_pb2' from 'google.api'”
【发布时间】:2019-11-27 13:57:56
【问题描述】:

我正在尝试从 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

【问题讨论】:

    标签: python-3.x google-cloud-platform google-bigquery


    【解决方案1】:

    正如您在帖子中提到的,解决方案是使用以下方法更新模块 googleapis-common-protos:

    pip install --upgrade googleapis-common-protos
    

    Common Protos 是整个 Google API 生态系统中的常见依赖项,它们可用作 BigQuery 等其他地方的依赖项。

    【讨论】:

      猜你喜欢
      • 2019-07-20
      • 2020-07-16
      • 2019-06-10
      • 2014-09-25
      • 2014-01-02
      • 1970-01-01
      • 1970-01-01
      • 2021-09-28
      • 2021-09-30
      相关资源
      最近更新 更多