What is Virtual Environment ?
A Virtual Environment is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects or Operating system dependencies as All operating systems has python dependencies.
It also helps in maintaining version compatibility e.g Django 1.4 is recommended to be used with python2.7 whereas Django 1.5 or 1.6 can use python 3.x, so in virtual environments developers can keep compatible setups in isolated form in same operating system with different versions of python.
How to Install ?
<code> $ pip install virtualenv </code>
Since “pip” is not a system package, it is a python package manager command line tool. To Install “pip” use following command:
<code> $ sudo apt-get install pip </code>
How to create virtual environment ?
Developers can use following command to set up any number of virtual environment:
<code> $ virtualenv my_environment_name </code>
How to activate and deactivate virtual environment ?
Change into your virtual environment folder through command line:
code> $ cd my_environment_name </code> <code> $ source bin/activate </code>
<code> $ deactivate </code>