簡體   English   中英

ImportError:沒有名為oauth2client的模塊

[英]ImportError: No module named oauth2client

我正在遵循Android的Google登錄文檔( https://developers.google.com/identity/sign-in/android/backend-auth )中的說明,並嘗試在我的Python代碼中實施令牌驗證。

我正在本地主機上開發。 出於某種原因,當我嘗試from oauth2client import client, crypt此導入時,收到此錯誤from oauth2client import client, crypt到我的Google App Engine后端,出現以下錯誤:

ImportError: No module named oauth2client.client`

我已經使用sudo pip install --upgrade google-api-python( https://developers.google.com/api-client-library/python/start/installation )安裝了oauth2。 安裝日志顯示:

Requirement already up-to-date: google-api-python-client in /usr/local/lib/python2.7/dist-packages/google_api_python_client-1.5.0-py2.7.egg
Requirement already up-to-date: httplib2>=0.8,<1 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Downloading/unpacking oauth2client>=2.0.0,<3 from https://pypi.python.org/packages/source/o/oauth2client/oauth2client-2.0.0.post1.tar.gz#md5=6309e12fe2bc0f038708e2c9ec4b1f69 (from google-api-python-client)
Downloading oauth2client-2.0.0.post1.tar.gz (66kB): 66kB downloaded
Running setup.py (path:/tmp/pip_build_root/oauth2client/setup.py) egg_info for package oauth2client
warning: no previously-included files matching '*' found under directory 'tests'
Requirement already up-to-date: six>=1.6.1,<2 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already up-to-date: uritemplate>=0.6,<1 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already up-to-date: pyasn1>=0.1.7 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.0,<3->google-api-python-client)
Requirement already up-to-date: pyasn1-modules>=0.0.5 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.0,<3->google-api-python-client)
Requirement already up-to-date: rsa>=3.1.4 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.0,<3->google-api-python-client)
Requirement already up-to-date: simplejson>=2.5.0 in /usr/local/lib/python2.7/dist-packages (from uritemplate>=0.6,<1->google-api-python-client)
Installing collected packages: oauth2client
Found existing installation: oauth2client 2.0.0-post1
Uninstalling oauth2client:
Successfully uninstalled oauth2client
Running setup.py install for oauth2client
warning: no previously-included files matching '*' found under directory 'tests'
Successfully installed oauth2client

我看到有人提供了答案,但是我不知道如何執行此處描述的符號鏈接: Google App Engine(python)ImportError:Google App Engine中沒有名為oauth2的模塊

我在想這與路徑有關,但是我不知道如何設置它以便全局安裝oauth2client。 我在VM上運行Ubuntu 14.04 LTS。

任何幫助,將不勝感激。

我剛剛從Google App Engine https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring中找到了此文檔,用於將第三方程序包安裝到該應用程序。

按照說明,我在項目文件夾中創建了一個名為“ lib”的文件夾,並在項目文件夾中也創建了一個名為appengine_config.py的文件。

在appengine_config.py文件中,輸入以下內容:

from google.appengine.ext import vendor
vendor.add('lib')

然后,在終端上的項目文件夾中,我輸入了sudo pip install -t lib google-api-python-client

這工作了! 導入不再引發錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM