Joe Reinsel
Joe Reinsel

Reputation: 65

App Deployment: Django not installing on server- AttributeError: 'module' object has no attribute 'lru_cache'

I am trying to deploy a Django App and for some reason, I keep getting this error. It seems to me that Django is not installed but it also errors when installing. Thank you for the help on this. I am deploying on Amazon EC2


(venv) ubuntu@ip----:~/quotes$ pip install Django
Collecting Django
  Using cached Django-2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-build-ceP6se/Django/setup.py", line 32, in 
        version = __import__('django').get_version()
      File "django/__init__.py", line 1, in 
        from django.utils.version import get_version
      File "django/utils/version.py", line 61, in 
        @functools.lru_cache()
    AttributeError: 'module' object has no attribute 'lru_cache'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ceP6se/Django/

Upvotes: 6

Views: 2832

Answers (2)

mahyard
mahyard

Reputation: 1238

According to the django 2.0 release notes, The Django 1.11.x series is the last to support Python 2.7 (Check it here)

So you can choose to use an older version of Django and then install it with this command:

pip install 'Django<2'

but if you decided to buildup your project using Django>=2.0 then you should create a virtual environment with python 3.4 or higher this way:

sudo apt-get update
sudo apt-get install python3 python3-pip
sudo -H pip3 install virtualenv
mkdir ~/myproject
cd ~/myproject
virtualenv -p `which python3` myprojectenv
source ~/myproject/myprojectenv/bin/activate
python -V

it should output something like this:

Python 3.X.Y

Now you are able to install the latest version of Django without any error:

pip install Django

Good luck,

Upvotes: 1

prakash sabarish
prakash sabarish

Reputation: 96

Django has stopped its support for Python 2 version, still you can try installing 1.11 version by using the below code.

pip install Django==1.11

Upvotes: 8

Related Questions