3
(myenv) wanjila@wanjila:~/Desktop/Python-Area/projects/Djangular$ pip freeze
djangorestframework==3.7.3
pkg-resources==0.0.0
(myenv) wanjila@wanjila:~/Desktop/Python-Area/projects/Djangular$ pip install django
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-qAnv7G/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'

------------------------------------

I keep getting that error whenever i try to pip install django while inside my virtualenv. How can i fix this.

4 Answers 4

11

As an alternative to wim's answer, if you can't upgrade your Python version for whatever reason, you can install Django 1.11 which is still compatible with Python 2.7:

pip install 'django<2.0'
Sign up to request clarification or add additional context in comments.

Comments

3

Make sure your Python version in the virtualenv is Python 3.4+.

Django 2.0 only supports Python 3.4+, and functools.lru_cache is only available in 3.2+.

To check the Python version in your current virtualenv:

python --version

To create a new virtualenv with python 3:

python3 -m venv venv --prompt=myenv

1 Comment

venv: error: unrecognized arguments: --prompt=myenv but this work python3 -m venv venv
0

This error is because of wrong picking of pip and python version . You can solve it by adding below lines in the ~/.bash_profile

  alias python='python3'
  alias pip='pip3.6' 

After that close the terminal and run the following command to install Django

  pip install Django==2.0

Comments

0

For latest version of Django, python 3 is required, thus try installing

pip install django==1.11

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.