Virtualenvwrapper
Virtualenvwrapper provides a series of commands that make working with virtual environments much more enjoyable. It puts all your virtual environments in one place.
Install (make sure the virtualenv is installed):
$ pip Install virtualenvwrapper$ export workon_home=~//usr/local/bin/virtualenvwrapper.sh
For Windows, you can use Virtualenvwrapper-win.
Install (make sure the virtualenv is installed):
$ pip Install Virtualenvwrapper-win
In Windows, the default path for Workon_home is%userprofile%envs.
Basic use
- Create a virtual Environment:
$ mkvirtualenv my_project
This will be ~/envs Create my_ Project folder.
- Working on a virtual environment:
$ Workon My_project
Alternatively, you can create a project that creates a virtual environment and $WORKON_HOME creates a project directory in. When you use it workon myproject , it is cd -ed to the project directory.
$ mkproject MyProject
virtualenvwrapper provides the tab completion function for the environment name. This is useful when you have many environments and it is difficult to remember their names.
workoncan also stop your current environment, so you can quickly switch between environments. The stop is the same:
- The stop is the same:
$ deactivate
- Delete
$ rmvirtualenv My_project
Other useful commands
-
lsvirtualenv
-
List all the environments.
-
cdvirtualenv
-
Navigate to the directory of the currently active virtual environment, such that you can browse it
site-packages .
-
cdsitepackages
-
Similar to the above, but directly into the
site-packages directory.
-
lssitepackages
-
displays
site-packages the contents of the directory.
A complete list of VIRTUALENVWRAPPER commands.
Virtualenv-burrito
With Virtualenv-burrito, you can use a single-line command to have virtualenv + virtualenvwrapper environment.
Autoenv
When you cd enter a contained .env directory, the environment is automatically activated by autoenv.
Use brew to install it on Mac OS x:
$ Brew Install Autoenv
On Linux:
$ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv'source ~/.autoenv/ activate.sh' >> ~/.BASHRC
Manage your virtual environment happily: Virtualenvwrapper