繁体   English   中英

错误:模块“google.cloud.bigquery_storage”没有属性“BigQueryReadClient”

[英]Error: module 'google.cloud.bigquery_storage' has no attribute 'BigQueryReadClient'

如何修复此错误?

错误:模块“google.cloud.bigquery_storage”没有属性“BigQueryReadClient”

无法查询 BigQuery 表并将结果保存到 Pandas DataFrame。包:

google-api-core==1.23.0
google-api-python-client==1.12.8
google-auth==1.23.0
google-auth-httplib2==0.0.4
google-auth-oauthlib==0.4.1
google-bigquery==0.14
google-cloud-bigquery==2.6.1
google-cloud-bigquery-storage==2.1.0
google-cloud-core==1.4.3
google-crc32c==1.0.0
google-resumable-media==1.1.0
googleapis-common-protos==1.51.0
grpcio==1.34.0
grpcio-gcp==0.2.2
pandas==1.1.5
pandas-gbq==0.13.2
pyarrow==2.0.0

询问:

def get_orders(bqclient,
               project_id,
               dataset_id,
               orders_table_id,
               datetime_start,
               datetime_end):

    query = f"""
        SELECT *
        FROM `{project_id}.{dataset_id}.{orders_table_id}`
        WHERE
            CreatedDatetime BETWEEN TIMESTAMP('{datetime_start}') AND TIMESTAMP('{datetime_end}')
    """
    print(query)
    orders = None
    try:
        query_job = bqclient.query(query)
        orders = query_job.result().to_dataframe()
    except Exception as exception:
        print(f'Error while getting orders: {exception}')
    finally:
        return orders

这段代码看起来像是在使用 google-cloud-bigquery 而不是 google-cloud-bigquery-storage。 bqclient是如何创建的? 是这样的吗?

from google.cloud import bigquery
bqclient = bigquery.Client()

尝试在您的代码中查找对BigQueryReadClient的引用并将其删除。 尝试删除google-cloud-bigquery-storage==2.1.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM