如何将模块从一个virtualenv复制到另一个 [英] how to copy modules from one virtualenv to another

查看:125
本文介绍了如何将模块从一个virtualenv复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将python模块从一个virtualenv复制到另一个虚拟机。如何完成?

解决方案

当您将他们从一个虚拟机移动到另一个相同的机器时,您可以轻松地执行以下操作:

  $ cp -r [env1] /lib/pythonX.X/site-packages/* [env2] /lib/pythonX.X/site-packages/ 
requires.txt 更安全,然后使用它来加载其他环境中的所有相同的模块。如果您愿意,可以手动创建文件,但使用 pip 更容易。

  $ pip freeze -E [env1]>或者,如果您的virtualenv已经被激活,您可以简单地:



  $ pip freeze>要求.txt 

然后,在您的其他环境中,您可以执行以下操作:

  $ pip install -E [env2] -r /path/to/requirements.txt 


Is it possibe to copy python modules from one virtualenv to another.If so how is this done?

解决方案

As long as you're moving them from one virtualenv to another on the same machine, you could easily just do:

$ cp -r [env1]/lib/pythonX.X/site-packages/* [env2]/lib/pythonX.X/site-packages/

However, if the environments are on different machines or utilizing different versions of python or some other major difference, it's probably not a good idea. In general it's much safer to generate a requirements.txt, and then use that to load up all the same modules in the other environment. You can create the file manually if you like, but it's easier to just use pip.

$ pip freeze -E [env1] > requirements.txt

Or, if your virtualenv is activated already, you can simply do:

$ pip freeze > requirements.txt

Then, in your other environment, you can do:

$ pip install -E [env2] -r /path/to/requirements.txt

这篇关于如何将模块从一个virtualenv复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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