2016-07-27 33 views
1

我一直在尝试使用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 

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

关键是生成的JSON文件。

回答

1

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

相关问题