For example:install python3.6
mkdir /usr/local/python3
wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -xzvf Python-3.6.5.tgz
cd Python-3.6.5
./configure --prefix=/usr/local/python3
make
make install
(ln -s /usr/local/python3/bin/python3 /usr/bin/python3)
Set python to python3 as default since model optimizer default is python3 based.
(apt-get remove python-pip python3-pip)
wget https://bootstrap.pypa.io/get-pip.py
apt-get install python3-distutils
python3 get-pip.py
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10