【问题标题】:Import Error on Google AppEngine : No module named oauth2Google AppEngine 上的导入错误:没有名为 oauth2 的模块
【发布时间】:2011-11-20 10:00:00
【问题描述】:

我正在运行 Google AppEngine。我安装了 oauth2。我成功地能够在程序中导入 oauth2,但是当我在本地主机上使用 GoogleAppEngine Launcher 运行我的 python 应用程序时,我收到以下错误

ImportError: No module named oauth2

我使用 Python2.7,它不是 GoogleAppEngine 的默认版本,但我在我的项目和 GoogleAppEngine Launcher 中都更改了 python 路径。

【问题讨论】:

  • from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app import oauth2 as oauth class MainPage(webapp.RequestHandler): def get(self): self.response. headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') application = webapp.WSGIApplication( [('/', MainPage)], debug=True) def main(): run_wsgi_app(application) if name == "main": main()
  • 来自以下链接的代码 - code.google.com/appengine/docs/python/gettingstarted/… with "import oauth2 as oauth"
  • 您是否在您的应用中捆绑了 oauth 库?它必须与您的应用一起上传,否则 App Engine 将无法访问它。

标签: google-app-engine oauth-2.0 python-2.7 importerror


【解决方案1】:

你看过this example吗?它显示了在 Google App Engine Python 项目中使用的 OAuth2。这可能会让您更好地了解如何使用 OAuth2 和 GAE。

【讨论】:

  • 这是您想要创建使用 oauth2 进行身份验证的应用程序的时候。我想使用 oauth2 连接到 Twitter。我得到的错误大多看起来像 PATH 错误
  • 我刚刚意识到这不是 oaoth2 的问题。任何外部库都存在导入错误。当我尝试导入 nltk 时发生相同的 ImportError
【解决方案2】:

您是否尝试使用 OAuth2 在 App Engine 上验证入站 HTTP 请求?

我刚刚在这里发布了一个完整的端到端示例: google app engine oauth2 provider

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 1970-01-01
    • 2018-07-10
    相关资源
    最近更新 更多