'module' object has no attribute 'lru_cache'

Aleksey Titov picture Aleksey Titov · Jul 26, 2018 · Viewed 8.4k times · Source

I'm getting this error in my logs with django app. I thought such errors occur when using Python 2.x, but in my virtual env Python - 3.6.5. Django - 2.0.7. VESTA Control Panel with wsgi. I will be grateful for the help.

Error log:

[Thu Jul 26 19:02:48 2018] [error] [client 86.32.36.143] File "/home/project/private/django/project/env/lib/python3.6/site-packages/django/utils/version.py", line 61, in [Thu Jul 26 19:02:48 2018] [error] [client 86.32.36.143] @functools.lru_cache() [Thu Jul 26 19:02:48 2018] [error] [client 86.32.36.143] AttributeError: 'module' object has no attribute 'lru_cache'

django.wsgi

import os, sys
sys.path.insert(0, '/home/user/web/project/private/django/project/env/lib/python3.6/site-packages')
sys.path.insert(0, '/home/user/web/project/private/django/project/project/src/shared/')
sys.path.insert(0, '/home/user/web/project/private/django/project/project/src/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'main.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Answer

Prashant picture Prashant · Aug 28, 2018

I had the same issue but then found out that my site was built with python3 and apache was configured for python2.7. The following link helped: Target WSGI script cannot be loaded as Python module