[英]Import Error : No module named django_orm
從oauth2client.django_orm導入CredentialsField
時,我得到:
Import Error: No module named django_orm
我已經安裝了先決條件: django-orm和python-oauth2 。
看起來OAuth2庫發生了變化:
將所有與django相關的代碼重構為oauth2client.contrib.django_util。 添加DjangoORMStorage,刪除FlowField。 (#546)
你可以在這里查看 。
也許你可以試試這樣的東西(運行它時我沒有遇到任何導入錯誤,但我不確定它是否有效):
from oauth2client.contrib.django_util.storage import DjangoORMStorage
from oauth2client.contrib.django_util.models import CredentialsField
有關Drive API指南的文檔不是最新的(最后更新於2015年5月)。
改為使用這些導入:
from oauth2client.contrib.django_orm import CredentialsField
from oauth2client.contrib.django_orm import FlowField
from oauth2client.contrib.django_orm import Storage
如果您正在關注API指南,那么更多導入將會中斷。 oauth2client的開發人員已將所有非核心模塊(django_orm,xsrfutil,appengine等)移至contrib 。 如果您獲得更多ImportError
請參閱oauth2client源代碼 。
看起來oauth2client庫已被棄用。 查看最新的google-auth
庫https://google-auth.readthedocs.io
要使用身份驗證令牌創建憑據對象: https : //google-auth.readthedocs.io/en/latest/user-guide.html#user-credentials
import google.oauth2.credentials
credentials = google.oauth2.credentials.Credentials(
'access_token')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.