check virtual environment python code example
Example 1: python virtual environment
python3 -m venv env
python -m virtualenv env
source env/bin/activate
Example 2: python create virtualenv
pip install virtualenv
cd projectfolder
python -m venv ./venv
Activate.ps1
activate.bat
Example 3: python virtual env
$ virtualenv --version
Example 4: how to check the existing virtual environments
lsvirtualenv -l
Example 5: python virtual env
$ virtualenv -p /usr/bin/python2.7 venv
Example 6: how to know if i'm in a virtual environment
import sys
sys.prefix == sys.base_prefix