我可以在不同的计算机上使用相同的虚拟环境吗 [英] Can I use same virtual environment on different computers
问题描述
在我办公室的电脑上,我在 Dropbox 文件夹中制作了 virtualenv one-for-rule-them-all
.我想在工作和家里都使用这种环境.这可能吗?(目前我没有成功)
On my office computer, I've made virtualenv one-for-rule-them-all
at the Dropbox folder. I want to use this environment both at work and at home. Is this possible? (currently I'm not successful)
推荐答案
考虑使用 virtualenv 的 relocatable
选项.如需完整文档,请参阅有关该主题的virtualenv 文档.
Look into using the relocatable
option of virtualenv. For full documentation, see the virtualenv documentation on the subject.
一个有趣的笔记:
此外,这不会使您的软件包跨平台.您可以移动目录,但它只能在其他类似的计算机上使用.一些可能导致不兼容的已知环境差异:不同版本的 Python,当一个平台使用 UCS2 作为其内部 unicode 表示而另一个平台使用 UCS4(编译时选项)时,明显的平台变化,如 Windows 与 Linux,或英特尔与英特尔.ARM,并且如果您有绑定到系统上的 C 库的库,并且这些 C 库位于不同的位置(不同的版本或不同的文件系统布局).
Also, this does not make your packages cross-platform. You can move the directory around, but it can only be used on other similar computers. Some known environmental differences that can cause incompatibilities: a different version of Python, when one platform uses UCS2 for its internal unicode representation and another uses UCS4 (a compile-time option), obvious platform changes like Windows vs. Linux, or Intel vs. ARM, and if you have libraries that bind to C libraries on the system, if those C libraries are located somewhere different (either different versions, or a different filesystem layout).
作为此方法的替代方案,我将简单地使用 setup.py 要求(install_requires
、setup_requires
)或 pip requirements.txt 文件管理您的项目/安装依赖项.这更加便携和跨平台.
As an alternative to this approach, I would simply manage your project/setup dependencies with setup.py requirements (install_requires
, setup_requires
), or pip requirements.txt file. This is much more portable and cross-platform.
这篇关于我可以在不同的计算机上使用相同的虚拟环境吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!