如何将 virtualenv 从 Windows 7 上传到 CentOS 6?

How to upload virtualenv from Windows 7 to CentOS 6?

我在一个需要特定(服务器)环境才能 运行 的项目中工作,因此它是在我的本地机器上开发的(windows 7),然后部署在远程服务器上(中央操作系统 6)。我使用 virtualenv,我能找到一种方法将我的虚拟环境从 windows 上传到 centOS 吗?有什么提示吗?非常感谢。

您可能不想直接上传您的虚拟环境,因为它可能包含特定于平台和体系结构的二进制文件。您可以做的是生成一组可用于重新创建虚拟环境的需求。引用优秀Hitchhiker's Guide to Python:

In order to keep your environment consistent, it’s a good idea to “freeze” the current state of the environment packages. To do this, run

$ pip freeze > requirements.txt

This will create a requirements.txt file, which contains a simple list of all the packages in the current environment, and their respective versions. You can see the list of installed packages without the requirements format using “pip list”. Later it will be easier for a different developer (or you, if you need to re-create the environment) to install the same packages using the same versions:

$ pip install -r requirements.txt

This can help ensure consistency across installations, across deployments, and across developers.