简体   繁体   English

我可以在不同的计算机上使用相同的虚拟环境吗?

[英]Can I use same virtual environment on different computers

On my office computer, I've made virtualenv one-for-rule-them-all at the Dropbox folder. 在我的办公室计算机上,我已经在Dropbox文件夹中将virtualenv one-for-rule-them-all I want to use this environment both at work and at home. 我想在办公室和家里都使用这种环境。 Is this possible? 这可能吗? (currently I'm not successful) (当前我不成功)

Look into using the relocatable option of virtualenv. 研究使用virtualenv的relocatable选项。 For full documentation, see the virtualenv documentation on the subject . 有关完整文档,请参阅主题上的virtualenv文档

One note of interest: 注意事项:

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). 一些已知的环境差异可能会导致不兼容:不同版本的Python,当一个平台使用UCS2进行内部unicode表示而另一个平台使用UCS4(编译时选项)时,明显的平台更改,例如Windows vs. Linux或Intel vs. Windows。 ARM,并且如果您具有绑定到系统上C库的库,则这些C库位于不同的位置(不同的版本或不同的文件系统布局)。

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. 作为这种方法的替代方法,我只需要使用setup.py需求( install_requiressetup_requires )或pip requirements.txt文件来管理您的项目/设置依赖项。 This is much more portable and cross-platform. 这是更加可移植和跨平台的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM