如何在 viralenv 上安装旧版本的 Django?

我想在虚拟环境中安装一些特定版本的包(在本例中是 Django)。我想不通。

我在 Windows XP 上,我成功地创建了虚拟环境,并且我能够运行它,但是我应该如何在其中安装我想要的 Django 版本呢?我的意思是,我知道使用新创建的 easy_install脚本,但是如何让它安装 Django 1.0.7呢?如果我做 easy_install django,它将安装最新版本。我尝试用各种方法将版本号 1.0.7放入这个命令中,但是都不起作用。

我该怎么做?

84234 次浏览

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

+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.

+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

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

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.