Application Deployment: Django is not installed on the server. AttributeError: the 'module' object does not have the 'lru_cache' attribute

I am trying to deploy a Django application, and for some reason I keep getting this error. It seems to me that Django is not installed, but these are also installation errors. Thanks for the help in this. I host 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 / 
+5
source share
2 answers

Django has stopped supporting version 2 of Python, but you can try installing version 1.11 using the code below.

pip install Django==1.11 
+8
source

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

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

 pip install 'Django<2' 

but if you decide to create your project using Django> = 2.0, you should create a virtual environment using python 3.4 or higher:

 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.XY 

Now you can install the latest version of Django without errors:

 pip install Django 

Good luck

+1
source

Source: https://habr.com/ru/post/1273867/


All Articles