So to handle this situation, we will use virtualenv tool. We will create a virtual environment for ProjectX, install all the dependencies, and then we will create a virtual environment for ProjectY, installing all its dependencies without hesitation as every library we install, ends up within the boundaries of the appropriate virtual environment. In our example, ProjectX will hold Django 1.7, while ProjectY will hold Django 1.8.
First of all, we will install virtualenv tool. I am using macOS, hence I will be using terminal for doing so. For Debian based linux distribution, use below command to do the installation.
$ sudo apt-get install python-virtualenv
2. Verify that installation completed successfully.
3. That completes the virtualenv installation.
Creating Virtual Environment:
1. Create a directory for your projectX using mkdir on desired path and navigate to the folder on terminal using cd .
2. After creating the virtual environment directory, we need to select the target python interpreter with project directory as you may have multiple versions.
5. You can also verify the target interpreter as shown below. It should be pointing to your project directory.
6. Launch python interactive shell to verify it is working fine
7. You can follow similar steps to create another project. Also if you want to deactivate project, you can simply run deactivate command on terminal as below.
NOTE: There is also another module called as venv which is suggested way of creating virtual environments as of Python 3.5