Virtualenv commands

Creating new environments

For creating a new virtual environment we just need to run the command “mkvirtualenv -p” plus the path to the python executable and the name for the new environment:

mkvirtualenv -p [Path to the python executable] [virtualenv name]

For example:

mkvirtualenv -p /usr/local/Cellar/python3/3.4.1/bin/python python3.4

Deactivate environment

Deactivate current environment:

deactivate

Switch environment

To activate a different environment:

workon [environment_name]

Listing environments

List all existing environments. There is two options: -b (brief) to display only the names and -l (long) which displays the names and hooks. Long is the default one.

lsvirtualenv -b

Remove environment

Remove environment:

rmvirtualenv [environment_name]

Adding folders to the Python path

Add specified directories to the Python path for the active virtualenv

add2virtualenv "path to your library"

Leave a Reply

Your email address will not be published. Required fields are marked *