102

I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out.

I'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to install the Django version I want into it? I mean, I know to use the newly-created easy_install script, but how do I make it install Django 1.0.7? If I do easy_install django, it will install the latest version. I tried putting the version number 1.0.7 into this command in various ways, but nothing worked.

How do I do this?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374

5 Answers5

166

There was never a Django 1.0.7. The 1.0 series only went up to 1.0.4. You can see all the releases in the tags section of the Django code repository.

However to answer your question, don't use easy_install, use pip. (If it's not already installed, do easy_install pip, then never touch easy_install again). Now you can do:

pip install Django==1.0.4
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • 3
    Although pip has some nice advantages over easy_install, "easy_install Django==1.0.4" would work just as well in this case. – Carl Meyer Jul 11 '10 at 13:52
  • 1
    this no longer works. at least not for easy_install - it leads to http://www.djangoproject.com/m/bad-installer.txt (and pip seems to be broken for python2.4 which is what i am using in virtualenv). yeah, it would be better if people used new versions, but some of us have to maintain old code... – andrew cooke Oct 22 '12 at 14:39
  • 1
    I asked a similar question in a comment to [this post](http://stackoverflow.com/a/19180081/123033), with a response suggesting: `pip install git+github.com/django/django@1.2.5#egg=django==1.2.5` – Dave Everitt Nov 05 '13 at 00:27
  • 'the tags section' link is dead, but releases with minor version can be found here : https://docs.djangoproject.com/en/2.0/releases/ oddly I didn't find this page from the django doc. replace '2.0' by '2.1' in some months.. – jerome Mar 03 '18 at 12:27
  • 1
    Also - to see all available versions you can do `pip install django==` (without a version number). – Frankie Simon May 14 '18 at 07:56
3

+1 on the previous poster's reply: use pip if you can. But, in a pinch, the easiest way is to install an older version would be to download the tarball from the downloads page or, if you have subversion installed, do an svn export of the release you want (they are all tagged here).

Once you have the version of Django you want, just run the following command inside the django directory:

python setup.py install

This will install that version of Django in your virtualenv.

mazelife
  • 2,069
  • 17
  • 12
3

+1 for already mentioned solutions.

I just wanna add another solution.

To install a specific version of Django (say 1.10.x),

  1. Clone the Django repo from Github.

    git clone https://github.com/django/django.git

  2. Go into the directory and checkout to the specific branch.

    cd django

    git checkout origin/stable/1.10.x

  3. Run install command.

    python setup.py install

Tahir Raza
  • 726
  • 1
  • 7
  • 20
2

pip install "django>=2.2,<3" To install djnago 2.2

Bartosz
  • 69
  • 4
  • 1
    Excellent! I wanted latest version of django 3, so I used: pip3 install "django>=3.2,<4". Note: Double quotes are needed for this command to work. – Anurag Jan 04 '22 at 16:20
1
pip install django==(the desired version ex: 1.8.4)

This will allow you to install the desired version, and I tried on OS:Windows10 and it perfectly worked.

R.SooraZ
  • 11
  • 2