Skip to content

Instantly share code, notes, and snippets.

@aakbar5
Created November 16, 2018 23:17
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 aakbar5/809e28af04e6e2557d68d267dc83ec7b to your computer and use it in GitHub Desktop.
Save aakbar5/809e28af04e6e2557d68d267dc83ec7b to your computer and use it in GitHub Desktop.
Manage multiple Python installations on Ubuntu machine
#
# Commands are tested on Ubuntu 14.04
#
# Install the python3 as Ubuntu 14.04 comes with Python2
sudo apt-get update -y && \
sudo apt-get install python-pip python3 python3-pip
# Let's manage two versions
# Ubuntu is already having pip2 as /usr/bin/pip. We need to remove it otherwise update-alternatives can't create symlinks
sudo rm /usr/bin/pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10 --slave /usr/bin/pip pip /usr/bin/pip2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 20 --slave /usr/bin/pip pip /usr/bin/pip3.5
# Machine is configured for python3 at this point, let's see
python --version
--- OR ---
pip --version
# To switch b/w different versions
sudo update-alternatives --config python
# To see available versions
sudo update-alternatives --list python
# To remove link
sudo update-alternatives --remove gcc /usr/bin/python3.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment