如何通过克隆当前本地环境来创建 virtualenv? [英] How to create a virtualenv by cloning the current local environment?

查看:31
本文介绍了如何通过克隆当前本地环境来创建 virtualenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 python 解释器,在我的本地系统上安装了许多模块,并且它已经调整到可以正常工作.

Suppose I have a python interpreter with many modules installed on my local system, and it has been tuned to just work.

现在我想创建一个 virtualenv 来冻结这些,以便将来升级时不会破坏它们.

Now I want to create a virtualenv to freeze these, so that they won't be broke by upgrading in the future.

我该怎么做?谢谢.

我不能使用 pip freeze,因为这是一个没有 pip 的集群,我没有安装它的权限.而且我也不想重新安装模块,我正在寻找是否有克隆方式.

I can't use pip freeze, because that's a cluster on which there's no pip and I don't have the privileges to install it. And I don't want the reinstall the modules either, I'm looking for that whether there's a cloning way.

推荐答案

运行 pip freeze 以创建系统上当前安装的所有模块的列表.然后创建一个 virtualenv 并安装这些模块.

Run pip freeze to create a list of all modules currently installed on the system. Then make a virtualenv and install these modules.

pip freeze > env_modules.txt
virtualenv my_env && cd my_env && source bin/activate
pip install -r ../env_modules.txt

这篇关于如何通过克隆当前本地环境来创建 virtualenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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