2016-02-26 110 views
1

我按照Google登录Android版文档(https://developers.google.com/identity/sign-in/android/backend-auth)中的说明操作,试图在我的Python代码中实现令牌验证。ImportError:没有名为oauth2client的模块

我正在开发本地主机。出于某种原因,当我尝试这个进口from oauth2client import client, crypt到我的谷歌应用程序引擎的后端我得到这个错误,我得到这个错误:

ImportError: No module named oauth2client.client` 

我已经安装的oauth2使用sudo PIP安装--upgrade谷歌API - python (https://developers.google.com/api-client-library/python/start/installation)。安装日志显示:

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: No module named oauth2 in google app engine

我想这有什么与路径有关,但我不知道如何设置,以便oauth2client在全局安装。我在VM上运行Ubuntu 14.04 LTS。

任何帮助,将不胜感激。

回答

4

我刚刚从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

这工作!导入不再抛出错误。

相关问题