Skip to content Skip to sidebar Skip to footer

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/Do

Solution 1:

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.

Solution 2:

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.

Solution 3:

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.

Answer : 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.

Solution 4:

How I solved it

I had django in a virtualenv and initially had installed uWSGI==2.0.19.1 system wide.

Following suggestions of other answers didn't solve my problem.

I then installed uWSGI==2.0.19.1 in my virtualenv, but the problem still happened.

Even the command which uwsgi pointed to my virtualenv:

/home/user/venv/bin/uwsgi

So I finally managed to make it work by calling uwsgi using the full path from my virtualenv:

/home/user/venv/bin/uwsgi --http :8001 --module my_django_project.wsgi

Then the problem has gone away.

I also see that when it was failing I had the message below:

detected binary path: /usr/local/bin/uwsgi

So I suppose just removing that /usr/local/bin/uwsgi would solve the problem.

Post a Comment for "Attributeerror: 'module' Object Has No Attribute 'lru_cache'"