【问题标题】:Google App Engine cannot find gdata moduleGoogle App Engine 找不到 gdata 模块
【发布时间】:2010-11-05 08:28:53
【问题描述】:

我可以毫无问题地在本地主机上运行一个简单的“Hello World”Google App Engine 应用程序。但是,当我将“import gdata.auth”行添加到我的 Python 脚本时,我得到“ImportError: No module named gdata.auth”。

我已经安装了 gdata 模块,并在我的 .bashrc 中添加了以下行:

导出 PYTHONPATH=$PYTHONPATH:/Library/Python/2.5/site-packages/

我还有什么需要做的吗?谢谢。

编辑:奇怪的是,如果我从 shell 运行 python 并输入“import gdata.auth”,我不会收到错误。

【问题讨论】:

    标签: python google-app-engine macos gdata google-data-api


    【解决方案1】:

    Google App Engine 不知道您的 .bashrc。确保gdata 目录(及其所有正确内容)位于应用程序的主目录下!

    请参阅this article,特别是(我引用):

    将此库与您的 Google 一起使用 App Engine 应用程序,只需放置 你的库源文件 应用程序的目录,并导入 像往常一样。来源 您需要上传的目录 您的应用程序代码是 src/gdata 和源/原子。然后,一定要打电话 这 gdata.alt.appengine.run_on_appengine 在每个实例上的函数 gdata.service.GDataService 对象。 没有什么比这更重要的了!

    【讨论】:

    • 这就是我在前一周为我工作的方式,只需将代码上传到 gdata 目录,你就应该被排序。
    【解决方案2】:

    gdata客户端库安装脚本将模块安装在ubuntu python安装错误的目录中。

    sudo mv /usr/local/lib/python2.6/dist-packages/* /usr/lib/python2.6/dist-packages
    

    【讨论】:

      【解决方案3】:

      尝试将其添加到您的脚本中:

      import sys
      sys.path.append('<directory where gdata.auth module is saved>')
      import gdata.auth
      

      【讨论】:

      • 不,我认为它不会引起痛苦 - 我投了反对票,因为我认为它没有回答问题。
      猜你喜欢
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 2011-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      • 2023-03-25
      相关资源
      最近更新 更多