我正在尝试在Google Cloud Shell中执行以下简单的python:
from google.cloud import bigquery
client = bigquery.Client()
print(client)
我收到以下错误:
./test.py: line 2: $'\r': command not found
./test.py: line 3: syntax error near unexpected token `('
'/test.py: line 3: `client = bigquery.Client()
有人可以让我知道我做错了什么吗?
非常感谢。
Cloud Shell是一个shell,而不是Python REPL。您应首先键入python
以进入Python REPL,然后输入您尝试运行的Python调用。例如:
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>
>>>