[Distutils] "activate" script for virtualenv

Dobes Vandermeer dobesv at gmail.com
Sat Oct 20 08:10:08 CEST 2007


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 at 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 at sjl-dev1:~/python-envs/trac$ cat activate
> bash --init-file .bash_init
> mgood at 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 at sjl-dev1:~/python-envs/trac$ which python
> /usr/local/bin/python
> mgood at sjl-dev1:~/python-envs/trac$ ./activate
> mgood at sjl-dev1:~/python-envs/trac$ which python
> /home/mgood/python-envs/trac/bin/python
> mgood at sjl-dev1:~/python-envs/trac$ exit
> mgood at sjl-dev1:~/python-envs/trac$ which python
> /usr/local/bin/python
>
> -- Matt
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig
>


More information about the Distutils-SIG mailing list