Virtualenv is a python tool for developers to create isolated development environments. In these isolated development environments i.e virtualenvs, developers can install packages which won’t affect other virtualenvs or with the other python packages. It solves your problem of dealing with package’s dependencies and at the same time maintains different versions that suits your project requirement.
Consider a scenario where you are working on project with Django 1.4 and then you have other project with Django 1.9. Its better to use virtualenv, where you can create two different development environments and install Python 2.7 in one and Python 3.0 in another. This way all your packages with different versions won’t get jumbled up and will make your life easier.
Setup Virtualenv on Mac
- To install virtual env you first need to install pip (python package management system). We will install pip systemwide.
sudo easy_install pip
- Now to install virtualenv, just type the following command and your mac’s password when prompted.
sudo pip install virtualenv
- Now to create a virtualenv, just type the following command
- To activate the virtualenv, you should navigate to myenv and type
- After you are done with your things, deactivate the virtualenv, type