Skip to content

Instantly share code, notes, and snippets.

@ByteCommander
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ByteCommander/a071c6762aa139c26082 to your computer and use it in GitHub Desktop.
Save ByteCommander/a071c6762aa139c26082 to your computer and use it in GitHub Desktop.
Script that should upgrade old pip-versions shipped with Ubuntu to the latest version available from PyPI
#! /bin/bash
upgrade_pip2 () {
# Installs latest version of pip for Python2, if any version is already installed
if pip2 &> /dev/null
then
echo "*** Uninstalling old version of pip for Python2..."
sudo apt-get remove python-pip -qq
echo "*** Installing/upgrading setuptools for Python2..."
sudo apt-get install python-setuptools -qq
echo "*** Using easy_install to get newest version of pip for Python2..."
sudo easy_install -U pip
fi
}
upgrade_pip3 () {
echo "*** Uninstalling old version of pip for Python3..."
sudo apt-get remove python3-pip -qq
echo "*** Installing/upgrading setuptools for Python3..."
sudo apt-get install python3-setuptools -qq
echo "*** Using easy_install to get newest version of pip for Python3..."
sudo easy_install3 -U pip
}
# find out if pip for Python2 is the default version if plain "pip" is run without version number
if pip -V | grep -q "(python 2"
then
# install pip for Python2 last, so that it will become the default
upgrade_pip3
upgrade_pip2
else
# install pip for Python3 last, so that it will become the default
upgrade_pip2
upgrade_pip3
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment