使用virtualenvwrapper重命名环境

问题:使用virtualenvwrapper重命名环境

我有一个名为的环境doors,我想将其重命名djangovirtualenvwrapper

我注意到,如果仅将文件夹重命名~/.virtualenvs/doorsdjango,我现在可以呼叫workon django,但是环境仍然提示(doors)hobbes3@hobbes3

I have an environment called doors and I would like to rename it to django for the virtualenvwrapper.

I’ve noticed that if I just rename the folder ~/.virtualenvs/doors to django, I can now call workon django, but the environment still says (doors)hobbes3@hobbes3.


回答 0

您可以使用:

cpvirtualenv oldenv newenv
rmvirtualenv oldenv

因此,在您的情况下:

cpvirtualenv doors django
rmvirtualenv doors

You can use:

cpvirtualenv oldenv newenv
rmvirtualenv oldenv

So in your case:

cpvirtualenv doors django
rmvirtualenv doors

回答 1

如果您这样做:

$ ack-grep -ai doors ~/.virtualenvs/django/bin

您会注意到,该文件将doors作为位置而不是django,您将使用新位置更改每个文件。

解决方案:重命名文件夹后,执行以下命令。

$ sed -i "s/doors/django/g" ~/.virtualenvs/django/bin/*

现在,如果您这样做:

$ workon django
(django)hobbes3@hobbes3

if you do:

$ ack-grep -ai doors ~/.virtualenvs/django/bin

you’ll notice that will have doors as location and not django, you’ll to change each file with the new location.

solution: after renamed the folder execute the command below.

$ sed -i "s/doors/django/g" ~/.virtualenvs/django/bin/*

now if you do:

$ workon django
(django)hobbes3@hobbes3