# Ubuntu/Debian
apt-get install python3-venv
python3 -m venv .venv
source .venv/bin/activate
# python 2
python -m virtualenv env
python3 -m venv env # create env
source env/bin/activate # activate env
deactivate # deactivate env
rm -r env/ # delete env in Linux
pip freeze # show all packages installed
pip install -r requirements.txt # install all packages
pip freeze > requirements.txt # create automatically requirements.txt
python -m venv newVirtualEnv //create new virtual env
source newVirtualEnv/bin/activate //activate-lunix|unix
./newVirtualEnv/Scripts/activate.ps1 //activate-Windows powershell
./newVirtualEnv/Scripts/activate.bat //activate-Windows cmd
cd newVirtualEnv/Scripts && . activate //activate-Windows git bash:
//--Windows Execution_Policies error--
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
// check if using venv active - CLI does not have (newVirtualEnv)
pip -V
#------FOR LINUX/MAC---------#
sudo apt-get install build-essential libssl-dev libffi-dev python-dev #installing requirements
sudo apt-get install -y python3-venv #installing venv
python3 -m venv env #creating virtual env
source env/bin/activate #activating virtual env
#-------FOR WINDOWS----------#
py -m pip install --user virtualenv #installing venv
py -m venv env #creating virtual env
.envScriptsactivate #activating virtual env
### install virtualenvwrapper ###
pip install virtualenvwrapper-win
### Add an environment variable WORKON_HOME to specify the path to store environments. By default, this is %USERPROFILE%Envs. ###
### ↓↓↓ use cmd or cmder (don't use ps terminal) for any of the following commands ↓↓↓ ###
### list venvs ###
lsvirtualenv
### create venv (automatically activated after creation) ###
mkvirtualenv <name>
### remove venv ###
rmvirtualenv <name>
### activate venv ###
workon <name>
### deactivate venv ###
deactivate
### General Syntax ###
mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] <name>
$ pip install virtualenv
python -m venv my_env
source my_env/bin/activate
python -m venv my_env
python -m venv venv
virtualenv venv --python=python3.10
#you can change python version (eg. python3.10) , Folder name (eg. venv)
$ virtualenv --version
$ source venv/bin/activate
python -m venv flask_env # Creating an isolated environment
source flask_env/bin/activate # Activate virtual environment
deactivate #deactivate
$ cd project_folder
$ virtualenv venv
$ virtualenv -p /usr/bin/python2.7 venv
python3 -m venv tutorial-env
// start it
source tutorial-env/bin/activate
// end it
deactivate
source <folder-env>/bin/activate
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:UsersAdminUbuntu", "User")
$ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
$ pip install --user pipenv