0
votes

I'm using ubuntu and I got python 2.7 and python 3.4.3 installed on my OS.

I'm trying to upgrade to Django 2. ButI get this error while trying to install it using pip install -U Django or pip install Django --upgrade:

Traceback (most recent call last): File "", line 17, in File "/tmp/pip_build_alex/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' Complete output from command python setup.py egg_info: Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_alex/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'

I've read this question and another one, only to see that answers are offering OP to install a lower version of django!, but that's not a real answer to such question.

I tried alias python=python3 to set python 3 as default python but failed to get a working solution.

How can I install Django 2 in a OS with 2 versions of python without getting this error?

1
did you try pip3 install Django --upgrade ? - Zoli
you should be using a virtualenv, and not installing packages to system python. Check out tutorial.djangogirls.org/en/django_installation - Jason
because if you do aliasing and other stuff with different python versions, you are going to seriously screw up your entire operating system. - Jason
@Jason I didn't permanently did that. - Alex Jolig

1 Answers

1
votes

I solved the issue by installing django using pip3. But since I didn't have pip3 package installed on my OS, first I had to install it using:

sudo apt-get update

sudo apt-get -y install python3-pip

Then I successfully installed Django 2.0 using:

pip3 install Django --upgrade