【问题标题】:Application Default Credentials do not exist应用程序默认凭据不存在
【发布时间】:2016-07-28 07:26:11
【问题描述】:

我一直在尝试使用 Google Cloud Vision API 来标记和分类图像,但我在凭据方面遇到了很多麻烦。我已经在 SDK 和 API 管理器本身中设置了凭据,并且我已经设置了 GOOGLE_APPLICATION_CREDENTIALS 环境变量,但是我运行代码的 IDE 仍然输出:

ApplicationDefaultCredentialsError: File C:\Users\elden\Documents\Credentials\My First Project-6c0f3ccb6309 (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!

这是获取凭据的代码部分:

credentials = gc.get_application_default()
service = build('vision', 'v1', credentials=credentials,discoveryServiceUrl=DISCOVERY_URL)

这里是导入:

import argparse
import base64
import httplib2

from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials as gc

我在 Windows 10 上运行 Spyder 2.7.11 32 位安装的代码。

密钥是生成的 JSON 文件。

【问题讨论】:

    标签: python-2.7 google-app-engine


    【解决方案1】:

    文件路径需要包含 .json 扩展名。

    【讨论】:

      猜你喜欢
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      • 2018-02-18
      • 2020-09-16
      • 1970-01-01
      相关资源
      最近更新 更多