重复的virtualenv [英] Duplicate virtualenv

查看:97
本文介绍了重复的virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我想要重复,那么我在virtualenv中有一个现有的环境,包含很多软件包,而且还有一个旧的Django版本。 >这个环境,

所以我可以有另一个环境,我可以在其中安装一个较新的Django版本,
但是保留已经在其他环境中的所有软件包?

解决方案

最简单的方法是使用pip生成需求文件。需求文件基本上是一个文件,其中包含您要安装的所有python软件包的列表(或者已经安装了由pip生成的文件的情况),以及它们的版本。



要生成要求文件,请转到原始的virtualenv,然后运行:

  pip freeze> require.txt 

这将为您生成 requires.txt 文件。如果您在自己喜欢的文本编辑器中打开该文件,您将看到如下:

  Django == 1.3 
Fabric == 1.0.1
etc ...

现在,编辑行说 Django == xx Django == 1.3 (或你想要安装在你的新virtualenv中的任何版本)



最后,激活您的 virtualenv,然后运行:

  pip install -r requirements.txt 

点数将自动下载并安装您的 requirements.txt 文件中列出的所有python模块,以您指定的任何版本!


I have an existing environment in virtualenv, with a lot of packages, but an old Django version.

What if I want to duplicate this environment,
so I can have another environment in which I can install a newer Django version,
but keeping all packages that are already in the other environment?

解决方案

The easiest way is to use pip to generate a requirements file. A requirements file is basically a file that contains a list of all the python packages you want to install (or have already installed in case of file generated by pip), and what versions they're at.

To generate a requirements file, go into your original virtualenv, and run:

pip freeze > requirements.txt

This will generate the requirements.txt file for you. If you open that file up in your favorite text editor, you'll see something like:

Django==1.3
Fabric==1.0.1
etc...

Now, edit the line that says Django==x.x to say Django==1.3 (or whatever version you want to install in your new virtualenv).

Lastly, activate your new virtualenv, and run:

pip install -r requirements.txt

And pip will automatically download and install all the python modules listed in your requirements.txt file, at whatever versions you specified!

这篇关于重复的virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆