Install Python 3.6 on Ubuntu

Install python 3.6 on Ubuntu 16.04, Ubuntu 16.10 and Ubuntu 17.04

The objective of this tutorial is to help you set up python 3.6 on Ubuntu. If you are on windows OS, you might want to check this other tutorial Python 3.6 download and install for windows.

Ubuntu 16.04 and Ubuntu 16.10 by default comes with two different versions of python installed, Python 2.7.12 and Python 3.5.2. At the time of this writing, the latest stable version of Python is 3.6, released on December 23rd, 2016. There are three different ways to install python 3.6 on Ubuntu:

  1. Installing python 3.6 on Ubuntu 16.10 and Ubuntu 17.04 from repository.
  2. Compile and install python 3.6 on Ubuntu 16.04.
  3. Install python 3.6 on Ubuntu 16.04 from PPA.

Before starting, check the default installed versions of python from the command line.

python --version
python3 --version

You should see something like:

python3.6 on ubuntu check

1. Installing python 3.6 on Ubuntu 16.10 and Ubuntu 17.04 from repository

If you are using Ubuntu 16.10 or Ubuntu 17.04, you can also install python 3.6 directly from repository. Python 3.6 is installed 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

Note: This method only works on Ubuntu 16.10 and Ubuntu 17.04. It does not work on Ubuntu 16.04 as the universe repository of Ubuntu 16.04 does not have python 3.6 installed. If you tried the command on Ubuntu 16.04, you will probably see something like:

python3.6 on ubuntu16.04 error

2. Compile and install python 3.6 on Ubuntu 16.04

First, we need to install some dependencies. We can do so by 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 the Python 3.6 source code from python.org. You can also directly download it by clicking here or from the command line as:

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

It might take some time for the ./configure and sudo make altinstall commands to run.

3. Install python 3.6 on Ubuntu 16.04 from PPA

You can install Python 3.6  from PPA using the commands below

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt update
sudo apt install python3.6

If Python 3.6 is correctly installed, you can use it by typing the following command:

python3.6

You will see something like:

I hope this tutorial helped you install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10 and Ubuntu 17.04.

 

About Aryal Bibek 15 Articles
Learner and practitioner of Machine Learning and Deep Learning. Ph.D. student at The University of Texas at El Paso. Admin and Founder at python36.com

2 Comments on Install Python 3.6 on Ubuntu

4 Trackbacks & Pingbacks

  1. Python 3.6 download and install for windows | Python 3.6
  2. Install GPU version of tensorflow | Python 3.6
  3. How to install OpenCV 3.4.0 on Ubuntu 16.04 | Python 3.6
  4. Introduction to programming using python3 | Python 3.6

Leave a Reply

Your email address will not be published.




This site uses Akismet to reduce spam. Learn how your comment data is processed.