6

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/
1
  • 1
    I have figured this issue out. the problem was that I needed to downgrade my version of Django from 2.7 > 1.11 because I was using an older version of python. Commented Dec 5, 2017 at 21:54

2 Answers 2

8

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
Sign up to request clarification or add additional context in comments.

2 Comments

Even better would be to pin the version so that the latest 1.11 would be used, such as: django >=1.11,<2.0
This is not a real answer and it's all around for these kinda error! OP needs a way to install django 2 not an older version
1

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,

1 Comment

Yes, Thank for your response. I have previously solved this problem by stepping back to Django 1.11. After doing that it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.