【发布时间】:2021-10-02 20:17:16
【问题描述】:
我尝试在 Jupyter 笔记本中从 Google BigQuery 运行 SQL 查询。 我按照https://cloud.google.com/bigquery/docs/bigquery-storage-python-pandas#download_query_results_using_the_client_library 的规定做所有事情。 我开设了一个客户账户并下载了 JSON 文件。 现在我尝试运行脚本:
from google.cloud import bigquery
bqclient = bigquery.Client('c://folder/client_account.json')
# Download query results.
query_string = """
SELECT * from `project.dataset.table`
"""
dataframe = (
bqclient.query(query_string)
.result()
.to_dataframe(
# Optionally, explicitly request to use the BigQuery Storage API. As of
# google-cloud-bigquery version 1.26.0 and above, the BigQuery Storage
# API is used by default.
create_bqstorage_client=True,
)
)
print(dataframe.head())
但我不断收到错误消息:
DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
我不明白我做错了什么,因为 JSON 文件看起来很好,并且文件的路径是正确的。
【问题讨论】:
标签: python google-bigquery jupyter-notebook