我正在尝试安装 Django,但出现以下错误,请告诉我问题出在哪里。
谢谢,
(ENV) AP-MacBook-Pro:bin $ sudo -H pip install django/
Processing ./django
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-sTRicb-build/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 60, 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 /private/tmp/pip-sTRicb-build/
答案1
lru_缓存仅适用于 Python 3。
笔记:问题表明安装步骤中使用了 python 2。此异常“AttributeError: 'module' object has no attribute 'lru_cache'”显示了这一点。您必须将 python 3 与 django 2.0 一起使用,因为 django 2.0 仅支持 python 3。