
I just set up a little script so that I can activate a particular virtualenv and easily exit it. Basically it just invokes a new bash subshell and sets the PATH to include the current bin dir: mgood@sjl-dev1:~/python-envs/trac$ cat activate bash --init-file .bash_init mgood@sjl-dev1:~/python-envs/trac$ cat .bash_init . ~/.bash_profile export PATH="`pwd`/bin:$PATH" So running ./activate will set up your path in the subshell, and exiting will restore your normal PATH. I don't really like running ~/.bash_profile again b/c I actually end up with it re-adding some stuff that's already in the PATH, but otherwise I lost my normal prompt coloring. Someone with more bash-fu know how to fix that? mgood@sjl-dev1:~/python-envs/trac$ which python /usr/local/bin/python mgood@sjl-dev1:~/python-envs/trac$ ./activate mgood@sjl-dev1:~/python-envs/trac$ which python /home/mgood/python-envs/trac/bin/python mgood@sjl-dev1:~/python-envs/trac$ exit mgood@sjl-dev1:~/python-envs/trac$ which python /usr/local/bin/python -- Matt

I thought virtualenv came with an activate/deactivate script - why not run bin/activate and then deactivate when you're done? Or am I misunderstanding what you mean by virtualenv ? On 9/28/07, Matt Good <matt@matt-good.net> wrote:
I just set up a little script so that I can activate a particular virtualenv and easily exit it. Basically it just invokes a new bash subshell and sets the PATH to include the current bin dir:
mgood@sjl-dev1:~/python-envs/trac$ cat activate bash --init-file .bash_init mgood@sjl-dev1:~/python-envs/trac$ cat .bash_init . ~/.bash_profile export PATH="`pwd`/bin:$PATH"
So running ./activate will set up your path in the subshell, and exiting will restore your normal PATH. I don't really like running ~/.bash_profile again b/c I actually end up with it re-adding some stuff that's already in the PATH, but otherwise I lost my normal prompt coloring. Someone with more bash-fu know how to fix that?
mgood@sjl-dev1:~/python-envs/trac$ which python /usr/local/bin/python mgood@sjl-dev1:~/python-envs/trac$ ./activate mgood@sjl-dev1:~/python-envs/trac$ which python /home/mgood/python-envs/trac/bin/python mgood@sjl-dev1:~/python-envs/trac$ exit mgood@sjl-dev1:~/python-envs/trac$ which python /usr/local/bin/python
-- Matt _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig

On Oct 19, 2007, at 11:10 PM, Dobes Vandermeer wrote:
I thought virtualenv came with an activate/deactivate script - why not run bin/activate and then deactivate when you're done? Or am I misunderstanding what you mean by virtualenv ?
It does now, but not at the time I wrote the script. Thanks to Ian for adding that. -- Matt
participants (2)
-
Dobes Vandermeer
-
Matt Good