Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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
如何为python设置google云帐户?_Python_Google Cloud Platform - Fatal编程技术网

如何为python设置google云帐户?

如何为python设置google云帐户?,python,google-cloud-platform,Python,Google Cloud Platform,我已经创建了一个谷歌云存储桶 现在我想通过python访问它 我已经在本地安装了google云存储 pip安装谷歌云存储 我已经定义了所有凭证和bucket的名称。这就是我正在做的: from google.cloud import storage client = storage.Client() bucket_id = 'myBucket' bucket = client.get_bucket(bucket_id) 这就是我得到的 DefaultCredentialsError: Coul

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

现在我想通过python访问它

我已经在本地安装了
google云存储

pip安装谷歌云存储

我已经定义了所有凭证和bucket的名称。这就是我正在做的:

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上的资源

问候,


Frederic

您是否尝试按照错误消息所述执行操作?@MadPhysicast是的,但我没有找到该帐户的.json文件key@emax也许您忘记创建服务帐户并下载json文件:是的,对不起,刚刚意识到