4

I'm trying to install Django via command prompt. I used pip install Django but got this message:

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-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/**

How do I fix this?

2 Answers 2

7

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"

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

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this, but only got "OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pytz'" from it.
That's a separate issue. You don't have permission to install into that directory. You could use sudo, but the recommended approach is to use a virtualenv. If you use a Python 3 virtualenv, then you can use Django 2.0.
1

To use Django 2.0 python 3 should be used. One way to do this is using a virtual environment. Create a python 3 virtual environment ( python3 -m venv myvenv ) and install Django 2.0 in it. Make sure to use pip from python 3 instead of 2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.