Python Virtual Environments

Installation

pip install virtualenv

Sometimes you have to specify pip3:

pip3 install virtualenv

Usage

Create a new folder where you want to start building the application or from within the GitHub folder:

mkdir virtualenv-demo

then type:

python3 -m venv env

To use the virtual environment type:

source env/bin/activate

The terminal should change and show that you’re now in a virtual environment ” (env)

Note: Within the folder that it’s been activated in, you should see a ” env ” folder. This is where python and where the modules you want to install are installed for this virtual environment.

To deactivate the virtual environment type:

deactivate