模块 'google.cloud' 中没有名称 'bigquery'

No name 'bigquery' in module 'google.cloud'

我正在使用 Anaconda Navigator 1.9.12、Python 3.6.4 和 VS Code 1.48.2。

我写了下面的代码:


    import pandas as pd
    from google.cloud import bigquery
    QUERY = """
        SELECT provider_city, provider_state, drg_definition, average_total_payments, 
        average_medicare_payments
        FROM 'bigquery-public-data.cms_medicare.inpatient_charges_2015'
        WHERE provider_city = "GREAT FALLS" AND provider_state = "MT"
        ORDER BY provider_city ASC
        LIMIT 1000
        """
    client = bigquery.Client.from_service_account_json('MedicareProject-xxxxxxxxxxxx.json')
    query_job = client.query(QUERY)
    df = query_job.to_dataframe()
    print ("Records Returned: ", df.shape )
    print ()
    print ("First 3 Records")
    print (df.head(3))

下面的代码行报错:from google.cloud import bigquery

错误信息是:

No name 'bigquery' in module 'google.cloud'

有人可以提出解决方案吗?

请安装 BigQuery 模块:

pip install google-cloud-bigquery

文档Link: https://pypi.org/project/google-cloud-bigquery/