0

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?

4

1 回答 1

1

我通过使用 pip3 安装 django 解决了这个问题。但由于我的操作系统上没有安装 pip3 包,首先我必须使用以下命令安装它:

sudo apt-get update

sudo apt-get -y install python3-pip

然后我使用以下方法成功安装了 Django 2.0:

pip3 install Django --upgrade
于 2017-12-29T21:09:19.393 回答