Sachin Patil

Sachin Patil

Free Software Developer | GNU Emacs Hacker

Python virtualenv
Published on Mar 04, 2014 by Sachin.

setv: Lightweight Python virtual environment manager

Update [March 28, 2019]: The setV project is migrated from GitHub to Gitlab.

Update [March 30, 2016]: I created setV as a separate project with installer and readme. This post is quite old.

I like to have a separate virtualenv for each python project. This ends up having virtual-environments for each project that I often find difficult to manage. All my virtual-environments resides in ~/virtualenvs directory but to activate/deactivate a virtual environment every time is a tedious job.

An easy solution to this is to install virtualenvwrapper, but then I have run commands like workon & mkvirtualenv. I don’t want to do that. Can I manage virtual environment using single command?. Luckily I have Bash function I find very handy. It lists all available virtual environments and can switch the environment as needed.


  • List all virtual environment

    1: setv [TAB] [TAB]
    2: # or
    3: setv -l
  • Switch virtual environment


    for example:

    setv rango
  • Create new virtual environment


    for example:

    setv -n foobar
  • Delete existing virtual environment


    for example:

    setv -d foobar
  • Deactivate virtual environment



The script is available here and can be downloaded via wget

wget https://raw.github.com/psachin/bash_scripts/master/virtual.sh


  • Set VIRTUAL_DIR_PATH value to your virtual environments directory-path in virtual.sh file. By default it is set to ~/virtualenvs/
  • Create a directory to hold all virtual environments

    mkdir ~/virtualenvs
  • Added this line to your .bashrc or any local rc script.

    source /path/to/virtual.sh