Python Virtual Environment

Purpose of Python virtual environment

  • To create an isolated environment for different Python projects

    • You can install a specific version of module on each project without worrying that it will affect your other Python projects.

Create Virtual Environment for Python 3

Check your python version

$ python --version
Python 3.6.9

Install virtualenv

pip install virtualenv

Create a virtual environment

python -m venv venv

activate your virtual environment

source venv/bin/activate

set up command alias in .bashrc

alias va="source venv/bin/activate"

Last updated