[Django]-Importerror: No module named memcache (Django project)

64👍

As you are using virtualenv you’d need to install this dependency from inside as you might have created the virtual environment before installed it as a system-wide library.

After activate your virtualenv type:

pip install python-memcached

This should solve it.

3👍

Based on pymemcache documentation

Since version 3.2, Django has included a pymemcache-based cache backend. See its documentation.
On older Django versions, you can use django-pymemcache.

So for Django 3.2+ use :

pip install pymemcache

1👍

First
run

pip install django-pylibmc

set you cache backend:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1.11211',
    }
}

Leave a comment