Skip to main content

Python Virtual Environment setup

python 2.7 venv

python2 venv setup

Create python 2.7 virtual environment in the venv folder.

mkdir venv;virtualenv -p /usr/bin/python venv
note

Add --system-site-packages option to include system packages to the virtual env while creating the env

python2 venv Activate

source venv/bin/activate

python 3 venv

python3 venv setup

Create python 3 virtual environment in the venv3 folder.

python3 -m venv `pwd`/venv3

python3 venv Activate

source venv3/bin/activate

start python virtual env

To start the python virtual environment

source <virtual-env-folder>/bin/activate

To stop: enter the command in the virtual environment

deactivate