lee-pai-long
1/20/2014 - 10:15 AM

Enable deadsnakes PPA, install Python 2.6, 2.7, 3.2 and 3.3, install easy_install and pip in to those versions

Enable deadsnakes PPA, install Python 2.6, 2.7, 3.2 and 3.3, install easy_install and pip in to those versions

#!/usr/bin/env bash
 
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
wget https://bootstrap.pypa.io/get-pip.py -O /tmp/get-pip.py
py_ver=`python -c 'import sys; print ".".join(str(x) for x in sys.version_info[:2])'`

for i in 2.6 2.7 3.2 3.3 3.4 3.5
do
  if [ "$i" != "$py_ver" ]
  then
    sudo apt-get -y install python$i python$i-dev
    sudo python$i /tmp/get-pip.py
  else
    echo "Default Python version is $i, installing dev libraries and pip only"
    sudo apt-get install -y python$-dev
    sudo python$i /tmp/get-pip.py
  fi
done