[英]Python - google-cloud library - error in Google Cloud Shell
I'm trying to execute the following simple piece of python within Google Cloud Shell: 我正在尝试在Google Cloud Shell中执行以下简单的python片段:
from google.cloud import bigquery
client = bigquery.Client()
print(client)
I get the following error: 我收到以下错误:
./test.py: line 2: $'\r': command not found
./test.py: line 3: syntax error near unexpected token `('
'/test.py: line 3: `client = bigquery.Client()
Could someone please let me know what is it I'm doing wrong? 有人可以让我知道我做错了什么吗?
Thanks a lot. 非常感谢。
Cloud Shell is a shell, not a Python REPL. Cloud Shell是Shell,而不是Python REPL。 You should type
python
first to enter the Python REPL, and then enter the Python calls you're trying to run. 您应该先输入
python
才能输入Python REPL,然后输入您要运行的Python调用。 For example: 例如:
Welcome to Cloud Shell! Type "help" to get started.
Your Cloud Platform project in this session is set to my-project.
Use “gcloud config set project [PROJECT_ID]” to change to a different project.
dustiningram@cloudshell:~ (my-project)$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import bigquery
>>> client = bigquery.Client()
>>> print(client)
<google.cloud.bigquery.client.Client object at 0x7f86802b5050>
>>>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.