Google cloud platform 将bigQuery表导出到google数据存储时遇到AttributeError异常
我正在尝试将表作为json文件从google bigQuery导出到google数据存储 运行此python代码段Google cloud platform 将bigQuery表导出到google数据存储时遇到AttributeError异常,google-cloud-platform,google-bigquery,google-python-api,Google Cloud Platform,Google Bigquery,Google Python Api,我正在尝试将表作为json文件从google bigQuery导出到google数据存储 运行此python代码段 from google.cloud import bigquery client = bigquery.Client() bucket_name = 'mybucket' destination_uri = 'gs://{}/{}'.format(bucket_name, 'myfile.json') dataset_ref = client.dataset('mydatase
from google.cloud import bigquery
client = bigquery.Client()
bucket_name = 'mybucket'
destination_uri = 'gs://{}/{}'.format(bucket_name, 'myfile.json')
dataset_ref = client.dataset('mydataset')
table_ref = dataset_ref.table('mytable')
job_config = bigquery.job.ExtractJobConfig()
job_config.destination_format = (
bigquery.DestinationFormat.NEWLINE_DELIMITED_JSON)
extract_job = client.extract_table(
table_ref, destination_uri, job_config=job_config
)
extract_job.result()
我收到了这个错误
AttributeError: module 'google.cloud.bigquery' has no attribute 'DestinationFormat'
我遵循官方文件
这里是我的python包版本
- 谷歌api核心(1.1.0)
- 谷歌认证(1.4.1)
- 谷歌云bigquery(0.31.0)
- 谷歌云核心(0.28.1)
- 谷歌可恢复媒体(0.3.1)
- googleapis通用原型(1.5.3)
关于请确保本地安装的版本具有所需的属性,可能您有一个较旧的版本:打开Python控制台、导入bigquery和dir it或help(bq)等,以查看该属性是否存在。如果没有,请pip更新gcloud包并重试 如果在pythonshell中该属性确实存在,但在运行脚本时却不存在,那么必须安装第二个版本的Python
可能还有其他原因,但让我们看看你发现了什么 能否尝试将
bigquery.DestinationFormat.NEWLINE\u DELIMITED\u JSON
替换为bigquery.job.DestinationFormat.NEWLINE\u DELIMITED\u JSON
?。这可能是文档中的一个bug。不完全是bug,更多的是在库发布之前重新发布了示例。此常量已添加到中的bigquery
模块中