Python virtual environments are used to create isolated python environments to avoid dependency and version conflicts, and also indirectly takes care of permission issues. But what is the easiest way to set it up, and use it, in Ubuntu?
Installation using distribute and pip
NOTE: If you don't want to touch system files or you don't have root, please see this question on stackoverflow. For everyone else please read on...
Install distribute and pip
According to the distribute website
Optional: Turn on bash autocomplete for pip
Use pip to install virtualenv and virtualenvwrapper
The reason we are also installing virtualenvwrapper is because it offers nice and simple commands to manage your virtual environments.
First we export the
now also create this directory
and put this export in our
We can also add some extra tricks like the following, which makes sure that if
Source ~/.bashrc to load the changes
Test if it works
Now we create our first virtual environment
You will see that the environment will be set up, and your prompt now includes the name of your active environment in parentheses. Also if you now run
you should see a lot of
You can deactivate your environment by running
and if you want to work on it again, simply type
Finally, if you want to delete your environment, type
Thanks to the author of this blogpost.