A single shell function that makes Python virtualenv easier to use.
Works for Mac OS and Linux.
Type ve env_name
to create or activate an environment. After you activate for the first time, your env name is remembered. Next time you can simply type ve
in that folder to quickly activate the same virtual env. This also works in its sub-folders.
Deactivate (exit): ve -e
List existing virtual environments: ve -l
Remove: ve -d env_name
Help
~$ ve -h
Simple virtualenv wrapper for Python
Usage:
ve [option] <name> [additional options]
Options:
without option Activate virtualenv, or create one if not exist.
Only when creating new environments, you can add
options that will be directed to virtualenv.
See `virtualenv -h` for more details.
-d, --delete <name> Delete a virtualenv.
-e, --exit Deactivate.
-h, --help Show this info.
-l, --list List existing virtualenvs (things in VENV_ROOT).
--history Edit (vim) the history file.
-p, --root Change the root path.
- install virtualenv
pip3 install virtualenv
- Star this repo :P, and
git clone
it to a folder. - Add these to your
.bash_profile
(Mac OS) or.bashrc
(Linux).
source $HOME/<path to ve.sh>
Example:
source $HOME/git/simple-virtualenv-wrapper/ve.sh
You can set an environment variable VENV_ROOT
in .bash_profile
to change the root directory. This is the path that holds all virtual environments.
VENV_ROOT=$HOME/.myvirtualenvs
If not set, it defaults to ~/virtualenvs
.