Can't install Django on Ubuntu, please help.

(studentsdb) fantbook@FantBook:/data/work/virtualenvs/studentsdb$ 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 "<string>", line 1, in <module> File "/tmp/pip-build-E7rbg6/django/setup.py", line 32, in <module> version = __import__('django').get_version() File "django/__init__.py", line 1, in <module> from django.utils.version import get_version File "django/utils/version.py", line 61, in <module> @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-E7rbg6/django/ 
  • Is the python version too old? - andreymal
  • @andreymal 2.7.12 - Oleksii Petrushynskyi
  • And you need at least 3.5 - andreymal
  • Delete your virtual environment (do not forget to deactivate ) and re-create it with the command virtualenv --python=/usr/bin/python3 /data/work/virtualenvs/studentsdb (or another similar, but --python not forget --python ) - andmal
  • @andreymal did not help :( - Oleksii Petrushynskyi

1 answer 1

in the standard library functools 'lru_cache' was added to 3 versions of python. therefore, I think that the 2nd version is used in your virtual environment.

make sure you have version 3 on ubunt OS. python3

Oftop, but it will be useful.

Each project launch requires activation of a virtual environment. For example, in order to run project A, you need to go to the virtual environment directory and run the command source my_env/bin/activate and this is not always pleasant, so virtualenvwrapper comes to the rescue.

simply by running the workon my_env you activate the Wirth. environment called my_env. read the documentation and so

  1. install pip3: sudo apt-get install python-pip3
  2. installation: sudo pip3 install virtualenvwrapper
  3. export WORKON_HOME=~/.virtualenvs
  4. export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
  5. source /usr/local/bin/virtualenvwrapper.sh
  6. mkvirtualenv myenv

as a result, the name of your virtual environment will be on the left: (myenv) login @ laptop_name: ~ $