Rename an environment with virtualenvwrapper
Asked Answered
P

2

127

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.

Pucka answered 2/3, 2012 at 20:39 Comment(0)
A
228

You can use:

cpvirtualenv oldenv newenv
rmvirtualenv oldenv

So in your case:

cpvirtualenv doors django
rmvirtualenv doors
Animal answered 23/9, 2012 at 2:39 Comment(3)
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: virtualenvwrapper.readthedocs.org/en/latest/…Spew
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.Stowell
I just got Python 3.7.3 after running cpvirtualenv, as expetcted.Saturant
B
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
Boondocks answered 23/4, 2012 at 19:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.