diff --git a/settings.py b/settings.py
index <HASH>..<HASH> 100644
--- a/settings.py
+++ b/settings.py
@@ -78,7 +78,7 @@ else:
 
 DEFAULT_CACHE_ALIAS = os.environ.get('CACHE_BACKEND', 'locmem')
 CACHES['default'] = CACHES.pop(DEFAULT_CACHE_ALIAS)
-if DEFAULT_CACHE_ALIAS == 'memcached':
+if DEFAULT_CACHE_ALIAS == 'memcached' and 'pylibmc' in CACHES:
     del CACHES['pylibmc']
 elif DEFAULT_CACHE_ALIAS == 'pylibmc':
     del CACHES['memcached']
Fixes an error in settings.