问题描述

 pip install Django 
pip install Django
Collecting Django
  Using cached `Django-2.0.tar.gz`

从命令<$ c中完成输出$ c> python setup.py egg_info :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-rcF9a5/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-rcF9a5/Django/**

如何修复

推荐答案

Pip正在尝试安装与Python 2不兼容的Django 2.0。您可以安装最新的1.11.x。

Pip is trying to install Django 2.0, which is incompatible with Python 2. You can install the latest 1.11.x release with

pip install "Django<2"

Django票务跟踪器上存在一个未解决的问题,可让pip安装正确的版本。

There’s an open issue on the Django ticket tracker to make pip install the correct version.

如果您刚刚开始使用Django,最好使用Python 3,因为1.11是支持Python 2的最新版本。

If you are just starting out with Django, it would be much better to use Python 3, because 1.11 is the last version to support Python 2.

这篇关于无法安装Django:命令&quot; python setup.py egg_info&quot;在/ tmp / pip-build-rcF9a5 / Django /中失败,错误代码为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!