如何在virtualenv上安装一个旧版本的Django ?

时间:2023-01-12 18:42:50

This may sound like a stupid question, since the very purpose of virtualenv is to this exactly: Installing some specific version of a package (in this case Django) inside the virtual environment. But it's exactly what I want to do, and I can't figure it out.

这听起来像是一个愚蠢的问题,因为virtualenv的目的就是要在虚拟环境中安装包的特定版本(在本例中为Django)。但这正是我想做的,我搞不懂。

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.

我在Windows XP上,我成功地创建了虚拟环境,我可以运行它,但是我应该如何将我想要的Django版本安装到它中呢?我的意思是,我知道要使用新创建的easy_install脚本,但是我如何让它安装Django 1.0.7呢?如果我安装django,它将安装最新的版本。我尝试以各种方式将版本号1.0.7放到这个命令中,但是没有任何效果。

How do I do this?

我该怎么做呢?

3 个解决方案

#1


116  

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.

从来没有一个Django值是1.0.7。1.0系列只有1.0.4。您可以在Django代码存储库的tags部分中看到所有的版本。

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:

但是要回答您的问题,不要使用easy_install,使用pip。(如果还没有安装,请执行easy_install pip,然后永远不要再碰easy_install)。现在你能做的:

pip install Django==1.0.4

#2


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

+1在前一张海报上的回复:如果可以,使用pip。但是,在紧急情况下,最简单的方法是安装旧版本,从下载页面下载tarball,或者,如果安装了subversion,则执行您想要的版本的svn导出(它们都标记在这里)。

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

获得想要的Django版本后,只需在Django目录中运行以下命令:

python setup.py install

This will install that version of Django in your virtualenv.

这将在您的virtualenv中安装该版本的Django。

#3


0  

+1 for already mentioned solutions.

+1表示已经提到的解。

I just wanna add another solution.

我想再加一个解。

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

要安装Django的特定版本(例如1.10.x),

  1. Clone the Django repo from Github.

    克隆来自Github的Django repo。

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

    git克隆https://github.com/django/django.git

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

    进入目录并签出到特定的分支。

    cd django

    cd django

    git checkout origin/stable/1.10.x

    git checkout /稳定/ 1.10.x起源

  3. Run install command.

    运行安装命令。

    python setup.py install

    python的设置。py安装

#1


116  

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.

从来没有一个Django值是1.0.7。1.0系列只有1.0.4。您可以在Django代码存储库的tags部分中看到所有的版本。

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:

但是要回答您的问题,不要使用easy_install,使用pip。(如果还没有安装,请执行easy_install pip,然后永远不要再碰easy_install)。现在你能做的:

pip install Django==1.0.4

#2


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

+1在前一张海报上的回复:如果可以,使用pip。但是,在紧急情况下,最简单的方法是安装旧版本,从下载页面下载tarball,或者,如果安装了subversion,则执行您想要的版本的svn导出(它们都标记在这里)。

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

获得想要的Django版本后,只需在Django目录中运行以下命令:

python setup.py install

This will install that version of Django in your virtualenv.

这将在您的virtualenv中安装该版本的Django。

#3


0  

+1 for already mentioned solutions.

+1表示已经提到的解。

I just wanna add another solution.

我想再加一个解。

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

要安装Django的特定版本(例如1.10.x),

  1. Clone the Django repo from Github.

    克隆来自Github的Django repo。

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

    git克隆https://github.com/django/django.git

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

    进入目录并签出到特定的分支。

    cd django

    cd django

    git checkout origin/stable/1.10.x

    git checkout /稳定/ 1.10.x起源

  3. Run install command.

    运行安装命令。

    python setup.py install

    python的设置。py安装