Rename an environment with virtualenvwrapper

PythonVirtualenvVirtualenvwrapper

Python Problem Overview


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.

Python Solutions


Solution 1 - Python

You can use:

cpvirtualenv oldenv newenv
rmvirtualenv oldenv

So in your case:

cpvirtualenv doors django
rmvirtualenv doors

Solution 2 - Python

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionhobbes3View Question on Stackoverflow
Solution 1 - PythonNickAldwinView Answer on Stackoverflow
Solution 2 - PythonBengineerView Answer on Stackoverflow