【问题标题】:Django and Google App Engine Helper not finding the ipaddr moduleDjango 和 Google App Engine Helper 找不到 ipaddr 模块
【发布时间】:2010-02-22 19:43:50
【问题描述】:

我正在尝试使用 tutorial 让 Django 在 GAE 上运行。

当我运行 python manage.py runserver 时,我得到下面的堆栈跟踪。我对 django 和 python 都是新手,所以我不知道我的下一步是什么(这是 Ubuntu Jaunty 顺便说一句)。 django 似乎没有找到 SDK 1.3.1 附带的 GAE 模块 ipaddr。

我如何让 django 找到这个模块?

/home/username/bin/google_appengine/google/appengine/api/datastore_file_stub.py:40: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5

/home/username/bin/google_appengine/google/appengine/api/memcache/__init__.py:31: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha
Traceback (most recent call last):
  File "manage.py", line 18, in <module>
    InstallAppengineHelperForDjango()
  File "/home/username/Development/GAE/myapp/appengine_django/__init__.py", line 543, in InstallAppengineHelperForDjango
    InstallDjangoModuleReplacements()
  File "/home/username/Development/GAE/myapp/appengine_django/__init__.py", line 260, in InstallDjangoModuleReplacements
    import django.db
  File "/home/username/Development/GAE/myapp/django/db/__init__.py", line 57, in <module>
    'TIME_ZONE': settings.TIME_ZONE,
  File "/home/username/Development/GAE/myapp/appengine_django/db/base.py", line 117, in __init__
    self._setup_stubs()
  File "/home/username/Development/GAE/myapp/appengine_django/db/base.py", line 128, in _setup_stubs
    from google.appengine.tools import dev_appserver_main
  File "/home/username/bin/google_appengine/google/appengine/tools/dev_appserver_main.py", line 82, in <module>
    from google.appengine.tools import appcfg
  File "/home/username/bin/google_appengine/google/appengine/tools/appcfg.py", line 53, in <module>
    from google.appengine.api import dosinfo
  File "/home/username/bin/google_appengine/google/appengine/api/dosinfo.py", line 25, in <module>
    import ipaddr
ImportError: No module named ipaddr

【问题讨论】:

    标签: django google-app-engine


    【解决方案1】:

    http://code.google.com/p/ipaddr-py/ 安装。

    关于问题的信息: http://code.google.com/p/google-app-engine-django/issues/detail?id=161#c3

    来自谷歌:

    > Hi, just apply this patch from: http://code.google.com/p/google-app-engine-
    django/source/detail?r=102
    
    -------
    
    Log message
    
    Adds new dependency, ipaddr, from SDK
    Affected files     expand all   collapse all
        Modify  /trunk/appengine_django/__init__.py diff
    ...         
    129 129             SDK_PATH,
    130 130             os.path.join(SDK_PATH, 'lib', 'antlr3'),
    131 131             os.path.join(SDK_PATH, 'lib', 'django'),
    132 +           os.path.join(SDK_PATH, 'lib', 'ipaddr'),
    132 133             os.path.join(SDK_PATH, 'lib', 'webob'),
    133 134             os.path.join(SDK_PATH, 'lib', 'yaml', 'lib'),
    134 135         ]
    

    【讨论】:

    • 不需要安装 ipaddr(正如 Iker 提到的),它已经在路径中。更新从 Google 解决方案复制的 init.py 应该足以将其自动包含在路径中。
    • GAE SDK 版本 102 包含此修复。
    【解决方案2】:

    app-engine-patch 也会发生这种情况

    解决方案是将$GOOGLE_APP_ENGINE/lib/ipaddr 添加到您的pythonpath,因为您必须使用其他依赖项,如antlr3 或yaml。

    【讨论】:

      【解决方案3】:

      按照这里的教程,我遇到了同样的问题: http://code.google.com/appengine/articles/appengine_helper_for_django.html

      我同意您需要将 ipaddr 添加到您的模块路径。我通过在我的 D:\Python26\Lib\site-packages 目录中创建一个名为 ipaddr.pth 的文本文件来做到这一点,它包含一行:

      D:\Program Files\Google\google_appengine\lib\ipaddr
      

      该模块的路径是什么。

      另外需要注意的是,您不需要按照建议安装适用于 Windows 的 Python,因为它不会自动获取 appengine SDK(或者至少对我来说似乎没有这样做)。请注意,我的系统 PATH 变量中有 D:\Program Files\Google\google_appengine\,但我不确定这是否有帮助(这样我就可以从 cli 中运行帮助脚本)。

      【讨论】:

        猜你喜欢
        • 2010-11-05
        • 1970-01-01
        • 1970-01-01
        • 2017-06-29
        • 2011-03-18
        • 2015-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多