Python virtual environment creates a isoloated workspace of python work. This helps in creating project specific virtual environment without worrying about inter-dependency package issues.

If a project requires a specific set of package versions then we can install those in that environment and use it.

Other project directory can have its own.

Download python

  1. Download the latest version python https://www.python.org/downloads/
  2. Install it and make sure to set it in the environment variables.
  3. Test to check if we can see the python on our git bash/ command prompt / Terminal.
┌─[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ python --version
Python 3.9.1
  1. Next install the virtual environment in the directory of you project. (Usually with a . so that it can be ignored in the .gitignore file.)
┌─[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ python -m venv .venv
  1. Next we have to activate/enable the virtual environment.
┌─[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ source .venv/Scripts/activate 
┌─(.venv)[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ pip list
Package    Version
---------- -------
pip        20.2.3
setuptools 49.2.1
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'd:\git_repos\python_start\.venv\scripts\python.exe -m pip install --upgrade pip' command.
  1. Installing new packages and check.
┌─(.venv)[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ pip install numpy
Collecting numpy
  Downloading numpy-1.20.1-cp39-cp39-win_amd64.whl (13.7 MB)
     |████████████████████████████████| 13.7 MB 6.8 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.20.1
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'd:\git_repos\python_start\.venv\scripts\python.exe -m pip install --upgrade pip' command.
┌─(.venv)[Zubair AHMED][AHMEDZBYR-WRK-HORSE][±][/d/GIT_REPOS/python_start]
└─▪ pip list
Package    Version
---------- -------
numpy      1.20.1
pip        20.2.3
setuptools 49.2.1
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'd:\git_repos\python_start\.venv\scripts\python.exe -m pip install --upgrade pip' command.

That’s it.. happy coding.