Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导入google cloud bigquery python模块时出错_Python_Google Bigquery - Fatal编程技术网

导入google cloud bigquery python模块时出错

导入google cloud bigquery python模块时出错,python,google-bigquery,Python,Google Bigquery,因此,我用google cloud bigquery one替换了google cloud软件包安装,因为google cloud已被弃用: Requirement already up-to-date: google-cloud-bigquery in /usr/local/lib/python3.5/dist-packages (1.5.0) 现在的问题是,当我尝试导入包时,我得到了一个语法错误,我真的不明白: import google-cloud-bigquery as bq

因此,我用google cloud bigquery one替换了google cloud软件包安装,因为google cloud已被弃用:

Requirement already up-to-date: google-cloud-bigquery in /usr/local/lib/python3.5/dist-packages (1.5.0)
现在的问题是,当我尝试导入包时,我得到了一个语法错误,我真的不明白:

    import google-cloud-bigquery as bq
             ^SyntaxError: invalid syntax
这是做我的头,有人可以帮助,什么是进口这个包的问题

使用:

从google.cloud导入bigquery

使用:


来自google.cloud import bigquery

语法错误的原因是减号是包或模块名称中的非法字符。通常,包将在实际包名中使用下划线,或具有嵌套结构,如本例所示:
将google.cloud.bigquery导入为bq

语法错误的原因是减号是包或模块名中的非法字符。通常,包将在实际包名中使用下划线,或具有嵌套结构,如本例所示:
导入google.cloud.bigquery作为bq

必须在该阶段实现
google cloud bigquery
语法;但是,正确的方法是使用google.cloud导入bigquery的
格式。您可以使用以下谷歌官方示例作为参考:

# Imports the Google Cloud client library
from google.cloud import bigquery

# Instantiates a client
bigquery_client = bigquery.Client()

# The name for the new dataset
dataset_id = 'my_new_dataset'

# Prepares a reference to the new dataset
dataset_ref = bigquery_client.dataset(dataset_id)
dataset = bigquery.Dataset(dataset_ref)

# Creates the new dataset
dataset = bigquery_client.create_dataset(dataset)

print('Dataset {} created.'.format(dataset.dataset_id))

googlecloudbigquery
语法必须在该阶段实现;但是,正确的方法是使用google.cloud导入bigquery的
格式。您可以使用以下谷歌官方示例作为参考:

# Imports the Google Cloud client library
from google.cloud import bigquery

# Instantiates a client
bigquery_client = bigquery.Client()

# The name for the new dataset
dataset_id = 'my_new_dataset'

# Prepares a reference to the new dataset
dataset_ref = bigquery_client.dataset(dataset_id)
dataset = bigquery.Dataset(dataset_ref)

# Creates the new dataset
dataset = bigquery_client.create_dataset(dataset)

print('Dataset {} created.'.format(dataset.dataset_id))