How to Install Python 3.6.1 in Ubuntu 16.04 LTS

July 6, 2017 — 12 Comments

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 install python3.6

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.5 /usr/bin/python3

I'm a freelance blogger who started using Ubuntu 5+ years ago and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me on Google Plus or email to

12 responses to How to Install Python 3.6.1 in Ubuntu 16.04 LTS

  1. Hi, thanks for the detailed post. However after following the instructions, this issue pop up:

    (terminal wouldn’t start, ImportError: cannot import name ‘_gi’)

    Is there a fix for this?

  2. Tabet Aoul Abdelkrim August 15, 2017 at 10:03 am

    using pyenv seems to work perfectly and gnome terminal works just fine

  3. I tried it and it works fine, but I was not able to correctly install python3-dev module, which then prevents to install some other modules.

  4. Hello sir, thank you very much.

  5. After following above procedures i went to install my own selection as follows:

    apt-get install python3.6 idle-python3.6 python3.6-doc python3.6-examples libpython3.6 libpython3.6-stdlib python-clang-3.6 python-lldb-3.6 libpython3.6-dbg python3.6-venv

    no error after the above command above.

    Linux ubuntu-net 4.4.0-93-generic #116-Ubuntu SMP Fri Aug 11 21:17:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

    to make python3.6 as the default, remove the rest of pythons and create a soft link to the python3.6:

    ls /usr/bin/python*
    /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.5 /usr/bin/python3.6 /usr/bin/python3m
    /usr/bin/python2 /usr/bin/python3 /usr/bin/python3.5m /usr/bin/python3.6m

    rm /usr/bin/python
    ln -s /usr/bin/python3.6 /usr/bin/python
    ln -s /usr/bin/python3.6m /usr/bin/pythonm

    Python 3.6.2 (default, Jul 20 2017, 08:43:29)
    [GCC 5.4.1 20170519] on linux
    Type “help”, “copyright”, “credits” or “license” for more information.


  6. Hi, Thank you. Single point of knowledge for all what is required in relevance of basic python installation.

  7. THANKS it helped me a lot.
    Rasheed from Ghana,Africa

  8. Shubham Dhananjay Dombe October 17, 2017 at 2:22 pm

    hello sir my terminal is not working what should i do

  9. what error E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

    what is problem

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>