导入中间件django.middleware.cache时出错:“没有名为memcache的模块”

1 投票
1 回答
12001 浏览
提问于 2025-04-17 20:48

共享主机:mochahost,设置了memcached。导入中间件django.middleware.cache时出错:“没有名为memcache的模块”

Traceback (most recent call last):

File "/opt/Python2.7/lib/python2.7/site-packages/mod_python/importer.py", line 1537, 
in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/opt/Python2.7/lib/python2.7/site-packages/mod_python/importer.py", line 1229, 
in _process_target
result = _execute_target(config, req, object, arg)

File "/opt/Python2.7/lib/python2.7/site-packages/mod_python/importer.py", line 1128, 
in _execute_target
result = object(arg)

File "/home2/minhhien/webapps/django/core/handlers/modpython.py", line 180, in handler
return ModPythonHandler()(req)

File "/home2/minhhien/webapps/django/core/handlers/modpython.py", line 142, in __call__
self.load_middleware()

File "/home2/minhhien/webapps/django/core/handlers/base.py", line 47, in 
load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % 
(mw_module, e))

ImproperlyConfigured: Error importing middleware django.middleware.cache: "No module 
named memcache"

请帮帮我!(抱歉,英语不好 :D)

1 个回答

6

memcached 是一个后台服务。要让你的程序使用它,你需要加载一个驱动模块,这样才能访问它。

在安装好 Memcached 之后,你还需要安装一个 memcached 的绑定库。对于 Python 来说,有几个可用的 memcached 绑定库;最常用的两个是 python-memcached 和 pylibmc。

引用来源

撰写回答