How to Install Python 3.6.1 in Ubuntu 16.04 LTS

Last updated: December 23, 2017

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 in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee:

25 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

  10. It works perfectly.Very helpful.

  11. After changing python default to python3.6 … Now I am not able to launch Terminal … What to do ? … please help anyone

  12. Reply anyone …. My Terminal , Startup Disc Creator etc are not being launched … Help me..

    • It’s a bug. A workaround is available in the end of the tutorial.

      • After fixing bug as you have given the workaround, then python runs in the default version of 2.7.12 itself. Although i have installed the version 3.6.3 and even selected the same version manually.

  13. Excellent post and tuto.
    Thanks a lot.
    I have now 3 version of Python working on my Ubuntu 16.04LTS x64.

  14. Excellent instructions. Python 3.6.3 is running on my Linux Mint 18.3 as Python3.

  15. hello sir,thanks for the post.However after following all the steps including the update step,i am getting below error for command python3 -v

    # /usr/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc’
    import ‘_collections_abc’ #
    import ‘os’ #
    # /usr/lib/python3.5/__pycache__/_sitebuiltins.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/_sitebuiltins.cpython-35.pyc’
    import ‘_sitebuiltins’ #
    # /usr/lib/python3.5/__pycache__/sysconfig.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/sysconfig.cpython-35.pyc’
    import ‘sysconfig’ #
    # /usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc’
    # /usr/lib/python3.5/plat-x86_64-linux-gnu/__pycache__/_sysconfigdata_m.cpython-35.pyc matches /usr/lib/python3.5/plat-x86_64-linux-gnu/
    # code object from ‘/usr/lib/python3.5/plat-x86_64-linux-gnu/__pycache__/_sysconfigdata_m.cpython-35.pyc’
    import ‘_sysconfigdata_m’ #
    import ‘_sysconfigdata’ #
    # /usr/lib/python3.5/__pycache__/sitecustomize.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/sitecustomize.cpython-35.pyc’
    # /usr/lib/python3/dist-packages/__pycache__/apport_python_hook.cpython-35.pyc matches /usr/lib/python3/dist-packages/
    # code object from ‘/usr/lib/python3/dist-packages/__pycache__/apport_python_hook.cpython-35.pyc’
    import ‘apport_python_hook’ #
    import ‘sitecustomize’ #
    import ‘site’ #
    Python 3.5.2 (default, Nov 23 2017, 16:37:01)
    [GCC 5.4.0 20160609] on linux
    Type “help”, “copyright”, “credits” or “license” for more information.
    # extension module ‘readline’ loaded from ‘/usr/lib/python3.5/lib-dynload/’
    # extension module ‘readline’ executed from ‘/usr/lib/python3.5/lib-dynload/’
    import ‘readline’ #
    import ‘atexit’ #
    # /usr/lib/python3.5/__pycache__/rlcompleter.cpython-35.pyc matches /usr/lib/python3.5/
    # code object from ‘/usr/lib/python3.5/__pycache__/rlcompleter.cpython-35.pyc’
    import ‘rlcompleter’ #
    please tell me the fix for it..thanks again

  16. patel shreeshiv January 19, 2018 at 6:10 pm

    Hi, But after follwing your all step ,even i can’t open My Terminallllll

  17. This works perfectly in Ubuntu 16.04. Thanks

  18. Ji M- you are the man! God bless you for your selflessness!

  19. thanks. It’s really helpful.
    but after this post terminal not open but after chng usr/bin/gnome-terminal python3.6 to python3 that terminal working fine.
    thank you again.