Version control of a development environment can be hard to implement on the same computer, unless you have different profiles or partitions for each version. Python has a feature called "virtual environments", which allow developers to create projects using a new version and maintain legacy projects using an older version. This won't require separate physical partitions or multiple profiles to implement.

To implement this, you must create the virtual environment by allocating a space on your storage drive and then setting up the version you need. If you are about to upgrade to a new version, but want to keep the older version (e.g. Python 2 to Python 3), you can keep the older version by creating a virtual environment for it.

Another way to use virtual environments is if you have to use different library and modules that you don't want to affect other projects. In that case you can just create another instance of a virtual environment of the same version but a different installation from your other projects.

The purpose of virtual environments is to create isolation of your projects with their own dependencies that won't affect other projects. There is also no limit to how many virtual environments you can create, so these are good for deploying projects in their own virtual sandbox which you can do with as you please.

6 Steps total

Step 1: Install virtualenv (for versions of Python 2.x)

From your terminal command prompt or console, type the following command.

$ pip install virtualenv

If you have Python 3 or Anaconda installed, you don't need to run this command. You will already have the venv command available.

Step 2: Create a working directory

First create a directory where you want to put your virtual environments.

$ mkdir
$ cd

This directory is where you can put all your virtual environments. This is in order to keep things organized to avoid confusion. At least you will know where you are installing the files for your virtual environments.

Step 3: Create your virtual environment

If you want to build a Python 3 virtual environment, use the command:

$ python3 -m venv env3

For Python 2 virtual environment, use the command:

$ virtualenv env3

This creates a virtual environment directory called env3.

Step 4: Activate your virtual environment

Under the directory you created for your virtual environments in step 2
( ), you can activate it by running the command:

$ source env3/bin/activate

Your prompt will then change to something similar to this:

(env3) $

Step 5: Verify your version

From within the virtual environment, type:

(env3) $ python --version

You may see either
Python 3.6.5 (Python 3) or
Python 2.7.10 (Python 2.x)

Step 6: End your virtual environment

To end your virtual environment, issue the command:

(env3) $ deactivate

Remember to end your virtual environment when you want to move on to another one you created.