Skip to content

Instantly share code, notes, and snippets.

@tiagocardosos
Last active February 10, 2018 18:24
Show Gist options
  • Save tiagocardosos/501b11e156621aa9e62909d4bfa9741a to your computer and use it in GitHub Desktop.
Save tiagocardosos/501b11e156621aa9e62909d4bfa9741a to your computer and use it in GitHub Desktop.
How to Install Python 3.6.1 in Ubuntu 16.04 LTS

This quick tutorial is going to show you how to install the latest Python 3.6.1 in Ubuntu 16.04 LTS via PPA.

Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default. You can install Python 3.6 along with them via a third-party PPA by doing following steps:

1. Open terminal via Ctrl+Alt+T or searching for “Terminal” from app launcher. When it opens, run command to add the PPA:

sudo add-apt-repository ppa:jonathonf/python-3.6

Type in your password (no visual feedback due to security reason) when it asks and hit Enter.

2. Then check updates and install Python 3.6 via commands:

sudo apt-get update
sudo apt-get -y install build-essential libssl-dev libffi-dev python3.6 
sudo apt-get -y install python3.6-gdbm python3.6-dev python3.6-venv virtualenv

Now you have three Python versions, use python command for version 2.7, python3 for version 3.5, and/or python3.6 for version 3.6.1.

3. To make python3 use the new installed python 3.6 instead of the default 3.5 release, run following 2 commands:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

Finally switch between the two python versions for python3 via command:

sudo update-alternatives --config python3

After selecting version 3.6:

python3 -V

UPDATE: due to this bug, gnome-terminal won’t launch after step 3, a workaround is running following commands to recreate the symlink:

sudo rm /usr/bin/python3
sudo ln -s python3.6 /usr/bin/python3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment