2016-07-27 36 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擴展名。

相關問題