Django-nonrel导入缓存失败。

9
我正在尝试在Google App Engine上设置django-nonrel,遵循此处的步骤:http://www.allbuttonspressed.com/projects/djangoappengine#installation 测试应用程序运行良好。
我可以在应用程序中使用缓存API,但是在测试和shell中却不行:
尝试在shell中输入from django.core.cache import cache会出现以下错误信息:
>>> from django.core.cache import cache
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "django-testapp/django/core/cache/__init__.py", line 182, in <module>
    cache = get_cache(DEFAULT_CACHE_ALIAS)
  File "django-testapp/django/core/cache/__init__.py", line 180, in get_cache
    return backend_cls(location, params)
  File "django-testapp/django/core/cache/backends/memcached.py", line 154, in __init__
    import memcache
ImportError: No module named memcache

同样地,试图执行./manage.py test会出现相同的错误。

为什么 ./manage runserver 可以正常工作,但是 ./manage shell 或者 ./manage test 却无法导入缓存?有任何想法吗?

3个回答

41

当我从1.5.5升级到Google App Engine 1.6.0时,我遇到了同样的问题。

通过安装python-memcached解决了这个问题:

pip install python-memcached

我在尝试在OSX上运行服务器时遇到了这个问题,但是现在已经解决了。谢谢! - Brendan

0
对于 Gentoo 用户,建议使用以下命令:
emerge -av dev-python/python-memcached


0

我也是这样做的:

sudo pip install python-memcached

然后重新启动Django,它就能工作了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接