繁体   English   中英

如何为python设置谷歌云帐户?

[英]How to set up google cloud account for python?

我创建了一个谷歌云存储桶。

现在我想通过 python 访问它。

我已经在本地安装了google-cloud-storage

pip install google-cloud-storage

我已经定义了所有凭据和存储桶的名称。 这就是我正在做的:

from google.cloud import storage
client = storage.Client()
bucket_id = 'myBucket'
bucket = client.get_bucket(bucket_id)

这是我得到的

DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

正如 Scratch'N'Purr 所说,

您需要按照此处所述设置身份验证

然后您的脚本将使用提供的凭据访问 GCP 上的资源。

问候,

弗雷德里克

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM