install python virtualenv ubuntu code example

Example 1: linux install pip

apt-get install python-pip	#python 2
apt-get install python3-pip	#python 3

Example 2: linux ubuntu install python 3.7

sudo apt-get install python3.7

Example 3: how to create a virtual environment in python ubuntu

python3 -m venv name_environment #this creates the virtual environment

source name_environment/bin/activate #this activates the virtual environment

#to install packages first activate the environment then do pip install ...

Example 4: how to activate virtual environment using ubuntu

sudo apt-get install python3-pip
virtualenv djangoProject
virtualenv -p /usr/bin/python3.6 djangoProject
source djangoProject/bin/activate

Example 5: python virtualenv ubuntu

$ pip install virtualenv
$ pip install virtualenvwrapper

// Append ~/.bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/$HOME/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh

Example 6: ubuntu activate venv

source venv/bin/activate