gpt4 book ai didi

android - 导入错误:没有名为 oauth2client 的模块

转载 作者:太空宇宙 更新时间:2023-11-04 08:50:43 24 4
gpt4 key购买 nike

我正在按照 Google Sign-In for Android 文档 (https://developers.google.com/identity/sign-in/android/backend-auth) 中的说明进行操作,并尝试在我的 Python 代码中实现 token 验证。

我正在本地主机上开发。出于某种原因,当我尝试将此导入 from oauth2client import client, crypt 导入我的 Google App Engine 后端时,我收到此错误:

ImportError: No module named oauth2client.client`

我已经使用 sudo pip install --upgrade google-api-python 安装了 oauth2(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

我看到有人提供了答案,但我不知道如何执行此处描述的符号链接(symbolic link):Google app engine(python) ImportError: No module named oauth2 in google app engine

我认为这与路径有关,但我不知道如何设置它以便全局安装 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

这成功了!导入不再引发错误。

关于android - 导入错误:没有名为 oauth2client 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35663508/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com