Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.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 获取DefaultCredentialsError(即使已设置环境)_Python_Google Cloud Platform - Fatal编程技术网

Python 获取DefaultCredentialsError(即使已设置环境)

Python 获取DefaultCredentialsError(即使已设置环境),python,google-cloud-platform,Python,Google Cloud Platform,在我的venv中,我将GOOGLE_应用程序_凭据链接到“apikey.json”文件 这个命令是: os.environ[“谷歌应用程序凭据”] 正确地给予 'apikey.JSON' 但在运行django应用程序时,我仍然会遇到相同的错误: DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitl

在我的venv中,我将GOOGLE_应用程序_凭据链接到“apikey.json”文件

这个命令是:

os.environ[“谷歌应用程序凭据”]

正确地给予

'apikey.JSON'

但在运行django应用程序时,我仍然会遇到相同的错误:

DefaultCredentialsError: Could not automatically determine 
credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application.

是否还有其他地方需要传递api json文件?

您在哪里运行django应用程序?请考虑凭据仅在测试环境中有效。如果您正在部署应用程序,则需要将其包括在app.yaml文件中。或者,如果您是从VM使用它,则可能需要直接从代码加载权限。@Ggrimaldo在本地运行。