Django 2.0+: AttributeError: 'module' object has no attribute 'lru_cache'


The error

While installing Django 2.0 you will get the following error:

 $ pip install django -U
Collecting django
  Using cached Django-2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/1f/pdmszzls4xs6px9gmf627ng40000gn/T/pip-build-LfCvmh/django/setup.py", line 32, in <module>
        version = __import__('django').get_version()
      File "django/__init__.py", line 1, in <module>
        from django.utils.version import get_version
      File "django/utils/version.py", line 61, in <module>
    AttributeError: 'module' object has no attribute 'lru_cache'


This means that you are probably using and old version of python. Django 2.0 requires Python 3.4+. If you need to still use python 2.7, you could try to use django 1.11.

The functools.lru_cache is only available in 3.2+. but django requires 3.4+!