126

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.

hobbes3
  • 28,078
  • 24
  • 87
  • 116

2 Answers2

226

You can use:

cpvirtualenv oldenv newenv
rmvirtualenv oldenv

So in your case:

cpvirtualenv doors django
rmvirtualenv doors
Quentin Pradet
  • 4,691
  • 2
  • 29
  • 41
NickAldwin
  • 11,584
  • 12
  • 52
  • 67
  • 7
    Just a heads up, there is currently a warning that `cpvirtualenv` may not work properly due to some hard-coded path information. Here's the docs: http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html#cpvirtualenv – modulitos Jun 01 '15 at 08:44
  • I just tried this and it created the "copy" with python2.7, even though the oldenv I was trying to copy used python3.7..... sad. – Leo Aug 28 '20 at 00:26
  • I just got Python 3.7.3 after running cpvirtualenv, as expetcted. – zenofewords Aug 31 '20 at 16:06
8

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
Bengineer
  • 7,264
  • 7
  • 27
  • 28