首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python - google-cloud库- Google Cloud Shell中的错误

Python - google-cloud库- Google Cloud Shell中的错误
EN

Stack Overflow用户
提问于 2018-09-01 00:48:43
回答 1查看 331关注 0票数 1

我正在尝试在Google Cloud Shell中执行以下简单的python代码:

代码语言:javascript
复制
from google.cloud import bigquery

client = bigquery.Client()

print(client)

我得到以下错误:

代码语言:javascript
复制
./test.py: line 2: $'\r': command not found
./test.py: line 3: syntax error near unexpected token `('
'/test.py: line 3: `client = bigquery.Client()

有人能告诉我我做错了什么吗?

非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2018-09-01 02:56:17

Cloud Shell是一个shell,而不是Python REPL。您应该首先输入python以输入Python REPL,然后输入您试图运行的Python调用。例如:

代码语言:javascript
复制
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>
>>>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52119750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档