英文:
google.auth.exceptions.DefaultCredentialsError: file was not found
问题
我已创建了Google Cloud Application Default Credentials,并将其存储在\ AppData \ Roaming \ gcloud中,供本地用户使用。
当我尝试在Python中实例化任何Google Cloud服务时,例如
storageclient = storage.Client(),
我收到一个错误
google.auth.exceptions.DefaultCredentialsError:找不到文件c:\ oldproject_id.json
它正在寻找一个我不再拥有的旧项目凭据JSON。如何重置它以使用Application Default Credentials JSON?
英文:
I have created Google Cloud Application Default Credentials and it is stored in \AppData\Roaming\gcloud for the local user.
When I try to instantiate any Google Cloud services in python, e.g.
storageclient = storage.Client(),
I get an error
google.auth.exceptions.DefaultCredentialsError: file c:\oldproject_id.json not found
It is looking for an old project credentials json I no longer have available. How do I reset it to make it use the Application Default Credentials json?
答案1
得分: 2
我通过移动JSON密钥文件并明确调用os.environ['GOOGLE_APPLICATION_CREDENTIALS']
并指定我想要使用的JSON文件名来解决了这个问题。
英文:
I was able to address this by moving the json key file and explicitly calling os.environ['GOOGLE_APPLICATION_CREDENTIALS'] with the json file name I wanted to use.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论