skip to Main Content

django_redis failing to import six from django.utils

Traceback:


Internal Server Error: /harem/reponse/
Traceback (most recent call last):
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/core/cache/__init__.py", line 50, in _create_cache
    backend_cls = import_string(backend)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django_redis/cache.py", line 8, in <module>
    from .util import load_class
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django_redis/util.py", line 8, in <module>
    from django.utils import six
ImportError: cannot import name 'six'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/utils/deprecation.py", line 93, in __call__
    response = self.process_request(request)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/contrib/sessions/middleware.py", line 20, in process_request
    request.session = self.SessionStore(session_key)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/contrib/sessions/backends/cache.py", line 17, in __init__
    self._cache = caches[settings.SESSION_CACHE_ALIAS]
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/core/cache/__init__.py", line 79, in __getitem__
    cache = _create_cache(alias)
  File "/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django/core/cache/__init__.py", line 53, in _create_cache
    "Could not find backend '%s': %s" % (backend, e))
django.core.cache.backends.base.InvalidCacheBackendError: Could not find backend 'django_redis.cache.RedisCache': cannot import name 'six'

Using:
django-redis 4.10.0
python 3.6

2

Answers


  1. django_redis is trying to import six from django.utils

    File “/home/yangcoco/.virtualenvs/Django_czbk/lib/python3.6/site-packages/django_redis/util.py”, line 8, in
    from django.utils import six

    However, six has been removed from django. Check Django 3.0 release notes here

    Either switch to bleeding edge django_redis or to Django 2.2 if you need to use this specific version of django_redis

    Login or Signup to reply.
  2. You could try installing the bleeding edge version of django-redis to fix the issue.

    This would enable you to use Django 3 that comes with features that can change how you’ll develop your app.

    To do so, just install the package directly from GitHub, if you’re using Pipenv like I am, just issue the following command:

    pipenv install git+https://github.com/niwinz/django-redis.git@master#egg=django-redis
    

    If you still want to stick to Django 2.X just edit the Django entry in your Pipfile to:

    django = "==2.*"
    

    Or issue the following command:

    pipenv install "django==2.*"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search