Introduction
Installing and Running Python


- right-click Computer and select Properties
- select Advance System Settings
- from the pop-up box select Advanced tab
- select Environment Variables
- select PATH and then Edit
You can now copy the value in your favorite text editor and look at it. Mine looks like the following.
- C:\Python\Python37\Scripts\;C:\Python\Python37\;C:\Python\Python36\Scripts\;C:\Python\Python36\;
- //and a few other values
When we execute the command "python" or "python --version", it looks into the "PATH" variable and finds Python 3.7 as the first match, it stops there and looks no further. Therefore, if we want to run "Python 3.6", we have to manually change the "PATH" variable or change the installation order which will, in turn, change the variable.
Setting Virtual Environment
- // upgrade pip to its latest version
- python -m pip install --upgrade pip
- // install virtualenv
- pip install virtualenv
If your requirement falls under any of the following categories,
- have only one Python version installed
- don't want to specify any Python version
- want to use default Python version (check your version by running "python --version" on the command line)
- // navigate to Desktop
- cd .\Desktop
- // create a new directory 'project-36'
- mkdir project-36
- // change currenct directory to 'project-36'
- cd .\project-36
- // create a virtual environment named 'venv', feel free to name it anything you like
- virtualenv venv -p C:\Python\Python36\python.exe
Notice the last command. With the attribute "-p" we have specified the Python version that we want our virtual environment to use. In our case, it's Python 3.6, which we had installed at "C:\Python\Python36". If you installed it at a different location, please pass the complete path here.
- // activate the virtual environment
- .\venv\Scripts\activate
-
- // check the python version
- python --version
-
- // list all packages installed by default
- pip list
-
- // deactivate the virtual environment
- deactivate

Summary
- installed Python (different versions)
- learned how to run specific Python version over command line
- created virtual environments, running different versions of Python, using virtualenv package
If you are interested to learn more and set up your Python virtual environment on Ubuntu (or other Linux based system), do check out my previous article where I walk you through each step in detail.

Sriharsha GadiyaramPosted Aug 5, 2019, 11:22 PM
"you must 'source' this script" error occurs whenever i try to activate virtual env.