Reputation: 276
Before I install virtualenvwrapper, I have some virtualenv installed in different location. Is there any way to collect them in virtualenvwrapper so that appear in workon command?
Upvotes: 4
Views: 2736
Reputation: 4805
Yes, that should be possible. Virtualenvwrapper allows you to custom define where your created environments will be stored:
export WORKON_HOME=/path/to/your/envs
If you point this to the location of your virtual environments from virtualenv, it should work. You should add this line to your .bashrc or .zshrc or whichever else shell you're using. The problem with this is that you wont be able to activate any environments that are not in that folder.
In that case it will probably work to just copy the whole virtualenv into where your virtualenvwrapper environments are created.
You can find out where that is like this:
mkvirtualenv test
workon test
which python
# Will print path to virtual python interpreter:
/path/to/virtualenvs/test/bin/python
Copy the desired environments so they are in the same folder
as the just created test environment. Here, this folder would be
/path/to/virtualenvs/
. I'll call it $VENVS
from now on.
After copying it should be something like /path/to/virtualenvs/my-other_env1
, /path/to/virtualenvs/my-other_env2
.
Assuming you created my-other_env1 and 2 before with virtualenv with default settings, copying my-other-evn1 can be done like:
cp ~/.virtualenvs/my-other-env1 $VENVS/
You can delete the test environment afterwards using
rmvirtualenv test
(Of course, if you already know what that folder is, it's not necessary to create the test environment.)
Upvotes: 1