How to Install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10, 17.04

Python is an open-source and beginner-friendly programming language. Ubuntu 16.04 and Ubuntu 16.10 come with two versions of Python, Python 2.7 and Python 3.5. At the time of this writing, the latest stable version of Python is 3.6, released on December 23rd, 2016. This tutorial is going to show you how to install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10, Ubuntu 17.04.

You can check python version on Ubuntu from command line

python --version

Installing Python 3.6 on Ubuntu 16.10, Ubuntu 17.04 from Repository

Python 3.6 is included in the universe repository of Ubuntu 16.10 and Ubuntu 17.04, so you can install it with the commands below.

sudo apt update

sudo apt install python3.6

Then check your version

python3.6 -V

Output:

Python 3.6.0

Now let’s see how to install the latest Python version on Ubuntu 16.04. We’re going to see how to build python from source. You can alternatively install it from PPA.

Method 1: Compile and Install Python 3.6 on Ubuntu 16.04

First, we need to install some build dependencies using the commands below.

sudo apt install build-essential checkinstall

sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Then, download Python 3.6 source code from python.org.

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz

Next, extract the tarball.

tar xvf Python-3.6.0.tar.xz

Now cd into the source directory, configure the build environment and install.

cd Python-3.6.0/

./configure

sudo make altinstall

make altinstall command skips creating symlink, so /usr/bin/python still points to the old version of Python and your Ubuntu system won’t break.

Once that’s done, you can use Python 3.6 shell by typing the following command:

python3.6

install python 3.6 ubuntu

To exit the Python 3.6 shell, type

quit()

Method 2: Install Python 3.6 on Ubuntu 16.04 from PPA

You can install Python 3.6 on Ubuntu 16.04  using this PPA.

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

sudo apt update

sudo apt install python3.6

That’s it!

I hope this tutorial helped you install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10 and Ubuntu 17.04.  As always, if you found this post useful, then subscribe to our free newsletter or follow us on Google+, Twitter or like our Facebook page.

Rate this tutorial
[Total: 42 Average: 4.1]