1

I made a few experimentations upgrading from python 2.6.5 to python 2.7.11 in order to get Django to work properly. Then I had to uninstall python 2.7.11 and get back to python 2.6.5 (compatibility issues with other projects). Now, when I try to install django 1.2.1 using pip install django==1.2.1 I get this error:

 C:\workspace\internal\trunk\ut_pr_01\src>pip install django==1.2.1
 Downloading/unpacking django==1.2.1   Running setup.py egg_info for
 package django
     Traceback (most recent call last):
       File "<string>", line 16, in <module>
       File "c:\users\maxim\appdata\local\temp\pip-build\django\setup.py", line
 32, in <module>
         version = __import__('django').get_version()
       File "c:\users\maxim\appdata\local\temp\pip-build\django\django\__init__.py",
 line 3, in <module>
         from django.utils.version import get_version
       File "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\version.py",
 line 7, in <module>
         from django.utils.lru_cache import lru_cache
       File "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\lru_cache.py",
 line 28
         fasttypes = {int, str, frozenset, type(None)},
                         ^
     SyntaxError: invalid syntax
     Complete output from command python setup.py egg_info:
     Traceback (most recent call last):

   File "<string>", line 16, in <module>

   File "c:\users\maxim\appdata\local\temp\pip-build\django\setup.py",
 line 32, in <module>

     version = __import__('django').get_version()

   File
 "c:\users\maxim\appdata\local\temp\pip-build\django\django\__init__.py",
 line 3, in <module>

     from django.utils.version import get_version

   File
 "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\version.py",
 line 7, in <module>

     from django.utils.lru_cache import lru_cache

   File
 "c:\users\maxim\appdata\local\temp\pip-build\django\django\utils\lru_cache.py",
 line 28

     fasttypes = {int, str, frozenset, type(None)},

                     ^

 SyntaxError: invalid syntax

 ---------------------------------------- Command python setup.py egg_info failed with error code 1 in
 c:\users\maxim\appdata\local\temp\pip-build\django Storing complete
 log in C:\Users\Maxim\pip\pip.log

It seems like the version of python is what causing the problem but previously I installed any django with same pip and same python versions.

My environment currently: pip 1.2.1, python 2.6.5, windows 10 64bit, needed django version: 1.2.1

Anyone with an idea?

3
  • And now you have compatibility problems with Django. Commented Jun 8, 2016 at 7:15
  • 1
    the thing is that previously I installed django 1.2.1 on same python 2.6.5 on same system... Commented Jun 8, 2016 at 7:19
  • 1
    django 1.2.1? You may not have been born when that version was released. Commented Jun 8, 2016 at 7:22

3 Answers 3

2

You can have multiple version of Python installed on Windows (what you seem to be using) without any problems. You just have to make sure the default version of Python is set correctly for your situation.

Instead of using an extremely outdated version of django, install the latest version of Python - just choose a different path for it from the installer. So instead of C:\Python27 set it to C:\Python-27 or anything else.

If you are installing Python 3, you don't have to change the path since Python 3 installs itself in C:\Program Files (the default location for programs in Windows) and thus will not clash with Python 2 which installs directly onto the C:\ drive.

Once you have an updated version of Python installed, you just have to make sure that you call that version of Python when you need to install django. To do this effectively, use a Python virtual environment.

Lets assume you have installed the latest version of Python 2 in C:\Python-27, here is how you would install the latest version of django against it:

First, you need to install the virtualenv package. Open a command prompt and then type the following (the > is the prompt, don't type that):

> C:\Python-27\Scripts\pip.exe install virtualenv

A few minutes later you should have virtualenv installed, next step is to install django inside a new virtual environment:

> C:\Python-27\Scripts\virtualenv.exe C:\%USER%\Desktop\django-env

Once that is done, you need to activate the environment, and install django:

> C:\%USER%\Desktop\django-env\bin\activate.bat
(django-env) > pip install django

Now you have the latest version of django installed on an updated version of Python.

Managing these environments can be difficult; so I would suggest downloading a Python IDE. PyCharm is what I use and there is a free community version available. It will make it easy to manage all the different versions of Python for you.

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

Comments

2

Python 2.6 does not have set literals.

 # in python 2.6 only this will work
 fasttypes = set(int, str, frozenset, type(None))

 # in python 2.7+ this will work as well
 fasttypes = {int, str, frozenset, type(None)}

The version of Django you are using is not compatible with python 2.6.5

Support for Python 2.6 was dropped in Django 1.7, so I'm not sure why you get this error when you try to install Django 1.2.1. Maybe a more recent version is residing in the temp\pip-build\ directory. Since it's called temp it should be safe to delete that directory.

In any case, Python 2.6 and the corresponding Django versions are insecure and unsupported. I highly recommend using a current version instead. If other projects need old deprecated Python versions, you should use virtual environments to isolate them.

Comments

0

The problem was solved by installing the Django version I need - 1.2.1 not using pip but downloading the files and manually running: python setup.py install .

1 Comment

Don't use this version of django please; use a current supported version that has the proper security patches applied.

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.