我試圖運行這裏提供的樣本https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py進行授權。導入錯誤:Google AnalyticsAPI授權
我注意到其他問題在SO中(ImportError: cannot import name SignedJwtAssertionCredentials)SignedJwtAssertionCredentials已被刪除,因此無法導入。
因此,我開始關注GitHub頁面(https://github.com/google/oauth2client/issues/401)和StackOverflow提供的解決方案。到目前爲止,沒有任何工作,我仍然看到同樣的錯誤。以下是我的代碼。
import argparse
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools
而且,這是我在運行上述代碼時收到的錯誤。
ImportError: cannot import name ServiceAccountCredentials
正如我在這個空間一個完整的新手,我試圖爲OAuth
(2.0.0和1.5.2)兩個版本做到這一點。安裝pyopenssl
後我也試過了,但還是失敗了。
您可以包括'進口oauth2client的輸出; oauth2client .__ version__'? – Forge
'進口oauth2client' 'oauth2client .__版本__'' 類型:STR 字符串形式:2.0.0-POST1 長度:11 文檔字符串: STR(對象= '') - > string' '返回一個很好的字符串表示形式的對象。 如果參數是一個字符串,則返回值是同一個對象.' –
現在,問題似乎已解決。幾個小時後我剛剛嘗試過,它工作。 –