Installing Virtual Environment for Python on Windows | Ubuntu | Linux | MacOs

Virtual environment is a tool that helps to create an isolated environment for installing dependencies in a Python project. If virtual environment is not available on your computer then follow these steps to install it:

  1. Make sure you have expected version of Python available on your computer. You can check this by running:
  2. py --version
    python3 --version
  3. Check if pip is already available on your computer by running this:
  4. py -m pip --version
    python3 -m pip --version
  5. If pip is not available on your computer then install it by running this:
  6. py -m ensurepip --default-pip
    python3 -m ensurepip --default-pip
  7. Install virtual environment by running this:
  8. py -m pip install --user virtualenv
    python3 -m pip install --user virtualenv