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: 68 Average: 4.4]

8 Responses to “How to Install Python 3.6 on Ubuntu 16.04, Ubuntu 16.10, 17.04

  • Felipe Ojeda
    5 months ago

    Method two works fine.

  • how to change path?

  • So I used method 1 to install Python3.6 on Ubuntu 16.04 LTS. The question is: how do I get the icon on my launcher? Thanks in advance!!

  • uwu cat
    5 years ago

    Method 1 also works for Py3.7.4 – just replace the tarball url with this one: https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz

  • sarbajit pal
    4 years ago

    Hello, altinstall worked beautifully. Thanks for sharing.
    I have an issue i would like to share, when I installed python3-pip it points to python3.5 in ubuntu 16.04. How do I make it point to current python3.6, thank you.

  • sarbajit pal
    4 years ago

    Hello again,
    Well i tried the following to understand python3.5 pip and python3.6 pip.
    > python3.5 $(which pip3) –version
    > python3.6 $(which pip3) –version
    which made me think that if i upgrade the pip using python3.6 -m pip i can specifically make pip3 point to python3.6

    so i downloaded the whl for pip v20 and installed using python3.6 -m pip install pip*.whl. And now pip3 points to python3.6

    Please let me know your thoughts, I am technically not a sound person.
    Thank you for your time.

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

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here