AttributeError: 'module' object has no attribute 'lru_cache'


Im getting the error as shown in title with this environment setup. Apache2 with mod_wsgi ,Python 3.5, Django 2.0.2 . I'm using virtualevn.

my virtual env is in : /home/santosh/Documents/project/project/ and django app is in /home/santosh/Documents/project/Reports

Below is the content of wsgi.py file

import os, sys sys.path.append('/home/santosh/Documents/project/Reports/Reports') sys.path.append('/home/santosh/Documents/project/Reports') sys.path.append('/home/santosh/Documents/project/project/lib/python3.5/site-packages') sys.path.append('/home/santosh/Documents/project/project/lib/python3.5') sys.path.append('/home/santosh/Documents/project/project/bin') from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Reports.settings") application = get_wsgi_application()



[Sun Feb 04 20:40:39.396427 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] mod_wsgi (pid=6428): Target WSGI script '/home/santosh/Documents/project/Reports/Reports/wsgi.py' cannot be loaded as Python module.

[Sun Feb 04 20:40:39.398284 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] mod_wsgi (pid=6428): Exception occurred processing WSGI script '/home/santosh/Documents/project/Reports/Reports/wsgi.py'.

[Sun Feb 04 20:40:39.398425 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] Traceback (most recent call last):

[Sun Feb 04 20:40:39.398475 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] File "/home/santosh/Documents/project/Reports/Reports/wsgi.py", line 30, in

[Sun Feb 04 20:40:39.398555 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] from django.core.wsgi import get_wsgi_application

[Sun Feb 04 20:40:39.398565 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] File "/home/santosh/Documents/project/project/lib/python3.5/site-packages/django/init.py", line 1, in

[Sun Feb 04 20:40:39.398591 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] from django.utils.version import get_version

[Sun Feb 04 20:40:39.398598 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] File "/home/santosh/Documents/project/project/lib/python3.5/site-packages/django/utils/version.py", line 61, in

[Sun Feb 04 20:40:39.398628 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] @functools.lru_cache()

[Sun Feb 04 20:40:39.398643 2018] [wsgi:error] [pid 6428:tid 140043928524544] [client] AttributeError: 'module' object has no attribute 'lru_cache'


I stumbled here from Google looking for a result for CentOS 7, so for anyone in a similar position, here's what fixed it for me:

When you yum install mod_wsgi, it installs the python2 version. This causes pain and suffering and crazy errors like in OP.

The solution is to install the python36 (or whatever python3 version you're using) version from the IUS repo in CentOS. I had to download from pkgs.org because my system doesn't have external internet access, so I'm not sure how to do it from yum, but I can confirm that once I installed a compatible version of mod_wsgi everything started working.


I ran

sudo apt remove libapache2-mod-wsgi sudo apt install libapache2-mod-wsgi-py3

to install the Python3 version on Ubuntu 18.04 and afterwards reloaded Apache, which solved the error for me.


After lots of trail and error and googling, finally i was able to run successfully.

I got the lru_cache error because, I did sudo apt-get install libapache2-mod-wsgi to install mod-wsgi. I think this might have installed to default python on Ubuntu 16.04 which is python2.7.

Solution: I uninstalled libapache2-mod-wsgi from ubuntu and installed it with pip install mod-wsgi and then finally copied the path of installed mod-wsgi from site-packages directory and updated it inside apache2/mods-available/wsgi.load file.

So its better to install mod-wsgi from virtualenv or normal python3 and then update apache files instead of installing libapache2-mod-wsgi directly on ubuntu.



  • AttributeError: 'module' object has no attribute 'lru_cache'
  • Powershell - Create new line for multiple array objects using Export-csv
  • ADB doesn't see my USB-connected device anymore
  • Testing subsequent values in a DataFrame
  • Detect when user navigates away from page
  • Button is reloading my page even if he's not a submit
  • GCC constexpr lambdas in constexpr functions and evaluation in compile time
  • how to unsubscribe for an observable
  • What exactly does lowering the priority of a constraint do?
  • LCS ALGORITHM ( example )
  • best way to remove the first word in a string in Java
  • Login View controller before SWRevealViewController
  • WPF binding to property of all items in a collection
  • How to change the default browser in visual studio code latest released?
  • Selenium can't locate iframe
  • Enable a text box only when 1 of the radio button is clicked
  • React Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Correctly Allocate And Fill Frame In FFmpeg
  • How do I get the standard Vim FTP command to work?
  • Creating and managing two independent random number sequences
  • Trigger powershell based on event log
  • Implementing and using MinMax with four in row (connect4) game
  • How to intercept local server web requests using Burp in Internet Explorer
  • Bazel failed to include a external static library .a
  • How to create mirrored image effect with CSS single element
  • Jenkins sending notifications to the wrong commit id
  • Could not resolve all files for configuration ':react-native-vector-icons:classpath'
  • Use PHP to Replace HTML with HTML
  • How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?
  • Implementation of timeout in LDAP
  • “Cannot open log for source” - Windows 7 - .NET web service - event log
  • 'Edit' function for forum posts and such
  • how to specify different css for ie
  • How to restrict use of third party camera app from your app
  • JQuery: Infinite input select
  • I am consuming a WCF service that requires headers from a .NET 2 website. How can I programmatically
  • How to specify generic type when the type is only known at runtime?
  • jQuery scrollTop if URL has hash
  • Send array to next viewcontroller iOs xcode [duplicate]
  • Apple Mach-O Linker error (“duplicate symbol”)