• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Python 3.6 on Ubuntu & LinuxMint

Written by Rahul, Updated on May 23, 2020

Python 3.6.10 is the latest stable version at the time of writing of tutorial. This Python version is available to download and install. This article will help you to install Python 3.6.10 on Ubuntu and Linuxmint operating system. To know more about this version visit Python official website.

Step 1 – Prerequsities

Use the following command to install prerequisites for Python before proceeding to the next steps.

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Step 2 – Download Python 3.6

Download Python using following command from python official site. You can also download the latest version in place of specified below.

cd /usr/src
sudo wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz

Now extract the downloaded package.

sudo tar xzf Python-3.6.10.tgz

Step 3 – Compile Python Source

Now use below set of commands to compile Python source code on your system. We use --enable-optimizations option with configure command to enable additional supports like SSL, bz2 support. With make command altinstall, to install it as separate Python, This will not overwrite the existing installation.

cd Python-3.6.10
sudo ./configure --enable-optimizations
sudo make altinstall

make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Step 4 – Check the Python Version

Finally, you have successfully installed Python 3.6 on your system. Let’s check the version installed of python using the below command.

python3.6 -V

Python 3.6.10

This will also configure PIP for you to install Python modules.

pip3.6 -V

pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

55 Comments

  1. Avatar Mike Valentin Reply
    December 8, 2020 at 2:01 pm

    Am getting the following error after following all instructions and successful install:

    [email protected]:/usr/src/Python-3.6.10$ pip3.6 -V
    bash: pip3.6: command not found

    Please advise….thanks!!

  2. Avatar Eric D. Rust Reply
    December 28, 2019 at 3:33 pm

    Thank you , excellent instruction

  3. Avatar Jorge Reply
    November 1, 2019 at 11:59 pm

    Thanks god work!!

  4. Avatar Philippe Reply
    July 17, 2019 at 8:56 am

    Thank you, it works well!

  5. Avatar Aidan Reply
    June 25, 2019 at 4:15 pm

    Does this work on Raspberry Pi 3 B+?

  6. Avatar haftom Reply
    April 22, 2019 at 3:55 pm

    I found the following error:
    The directory ‘/home/haftom/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
    The directory ‘/home/haftom/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

    • Avatar rnickle Reply
      May 30, 2019 at 8:07 pm

      Did you ever find a resolution to this?

  7. Avatar popzzy Reply
    April 1, 2019 at 8:54 pm

    thanks a lot bro . i just didn’t know who i would start

  8. Avatar Dogo Reply
    March 15, 2019 at 7:14 am

    Thanks a bunch! Worked like a charm

  9. Avatar Susi Juniastuti Reply
    January 16, 2019 at 8:53 am

    It was helpfully. Very easy. First, I installed Python3.6.1 from cd installer on my pc ,ubuntu 16.04, then process stopped . There were some errors.
    I tried using this tutorial . Works !

    Thanks a lot

  10. Avatar Rachel Reply
    October 30, 2018 at 3:55 pm

    I can’t thank you enough, this was very helpful, god bless!

  11. Avatar Mahendra Reply
    September 22, 2018 at 7:27 am

    I have installed python 3.6.6 successfully on ubuntu 14.04 but PyCharm is not detecting 3.6 as an interpreter.
    Can you please help me with same?

  12. Avatar Last_Samurai Reply
    September 7, 2018 at 3:14 pm

    Thank’s very much brother!!!

    Good luck!!

  13. Avatar Ömer yalçın Reply
    July 29, 2018 at 4:34 pm

    Hi Rahul than you for sharing. I setup successfully python 3.6.6 on my pc, because of you , but I can not setup python idle 3.6.6 . When I try setup idle , it was for python 3.6.6 . How I can fix this problem.

  14. Avatar Barrowman Reply
    July 1, 2018 at 7:28 pm

    Just tried this but it fails
    Checking for python version >= 2.7.0 : 3.6.4
    python-config : /usr/local/bin/python3.6m-config
    Asking python-config for pyembed ‘–cflags –libs –ldflags’ flags : yes
    Testing pyembed configuration : yes
    Asking python-config for pyext ‘–cflags –libs –ldflags’ flags : yes
    Testing pyext configuration : Could not build python extensions
    The configuration failed
    (complete log in /tmp/pip-build-k_6fcvg_/wxPython/build/waf/3.6/gtk3/config.log)
    Command ‘”/usr/local/bin/python3.6″ /tmp/pip-build-k_6fcvg_/wxPython/bin/waf-2.0.7 –wx_config=/tmp/pip-build-k_6fcvg_/wxPython/build/wxbld/gtk3/wx-config –gtk3 –python=”/usr/local/bin/python3.6″ –out=build/waf/3.6/gtk3 configure build ‘ failed with exit code 1.
    Finished command: build_py (0.782s)
    Finished command: build (3m45.45s)
    Command ‘”/usr/local/bin/python3.6″ -u build.py build’ failed with exit code 1.

  15. Avatar Doc Reply
    June 17, 2018 at 9:16 pm

    Make sure you update pip3.6 with sudo -H pip3.6 install –upgrade pip

  16. Avatar Satish Reply
    May 7, 2018 at 4:25 am

    Nice but did not mention how to run python after installation

    • Avatar arpit awasthi Reply
      August 7, 2018 at 2:05 pm

      just type “python3.6” after successfully installing it.
      voila..!!

  17. Avatar nico Reply
    April 14, 2018 at 3:58 am

    Really good man!
    great, easy & happy intall.
    thanks a lot !

  18. Avatar buy moko Reply
    April 4, 2018 at 1:08 pm

    Hi. i have tried this. Now I have python 2.7, 3.6 and 3.6 in my system. but my Pycharm cannot find the 3.6 in selecting interpreter settings. How can I fix this?

  19. Avatar Marco Korb Reply
    March 29, 2018 at 4:17 pm

    Thanks

  20. Avatar sharath Reply
    March 27, 2018 at 11:00 am

    Thanks brother

  21. Avatar Shawn Reply
    March 26, 2018 at 10:11 pm

    great article. quick question: why skip ‘make’ before run ‘make altinstall’?

  22. Avatar Diego Misael Blanco Murillo Reply
    March 4, 2018 at 9:17 pm

    Thank you bro.

  23. Avatar Himanshu Reply
    March 4, 2018 at 5:20 am

    Thanks for the article. I had been facing the error described at this link: https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3

    Your comment there brought me to your article. And I tried reinstallation after adding the dependencies you had mentioned. It works fine now. Thanks Again 🙂

  24. Avatar AM Reply
    February 28, 2018 at 2:57 pm

    Having installed python3.6.4, how do i uninstall it?

  25. Avatar Sky Reply
    February 22, 2018 at 1:36 am

    Okay, this is legitimately the best Linux Mint guide I’ve seen on this topic. I never realized this website had actual working installation guides.

  26. Avatar Bob Reply
    February 16, 2018 at 8:37 am

    Thanks. Seems to work on Linux mint 18.3

    Alias existing:

    $ python

    Refers to v 2.712

    $ python3

    Refers to v 3.52

    Is it safe to replace these aliases with the latest Python version or will this break a lot of things in linux?

  27. Avatar Spork Reply
    January 30, 2018 at 8:28 pm

    Might want to try “sudo make -j altinstall” … The -j option tells make to use all your CPU cores, so it builds faster if you have more than one core.

  28. Avatar Sander Reply
    January 24, 2018 at 3:16 pm

    Nice to have instructions that actually work for ones! Thank you very much

    • Avatar Mister Reply
      February 5, 2018 at 4:01 am

      Where’d you find those? I think installing from source DID work for me once…but I won’t swear to it.

  29. Avatar James Peres Reply
    January 13, 2018 at 1:13 pm

    thanks for your text!

  30. Avatar Martin Taylor Reply
    January 12, 2018 at 10:13 pm

    Very helpful article, thanks

  31. Avatar Jesse Reply
    January 9, 2018 at 6:26 pm

    you should add this to the list of dependencies in step 1 so that lzma package works. I found that python 3.6.3 won’t have lzma support without this. I’m on ubuntu 17.04 btw.

    sudo apt-get install liblzma-dev

  32. Avatar Hiago Reply
    January 9, 2018 at 1:55 am

    Thanks 😀 It works fine for 3.6.4, replacing “Python-3.6.3” to “Python-3.6.4”

  33. Avatar Shayne Reply
    January 1, 2018 at 12:46 pm

    Followed all the instructions above , had no errors. Thanks you.

  34. Avatar kishore Reply
    September 21, 2017 at 3:59 am

    after completion of all the commands how to find my python folder like where it is installed

  35. Avatar sanjana Reply
    September 15, 2017 at 8:46 am

    how to remove python 3.6 ??wu=ithout effecting 2.7, 3.2

  36. Avatar Bhasha Reply
    September 1, 2017 at 7:41 am

    how did you get the certification? what exam should i write? please share it with me. thank you. 🙂

  37. Avatar Paul Reply
    August 29, 2017 at 3:04 pm

    It works with a little modifications. Thx a lot!

    • Rahul Rahul K. Reply
      August 30, 2017 at 4:09 am

      Hi Paul,

      What modifications you did? Please share with our readers.

      • Avatar Don Reply
        September 2, 2017 at 2:21 am

        The latest release is now 3.6.2 and the instructions given above, using the URL you outline but replacing “3.6.0” with “3.6.2” does not work. The error for both “3.6.0” and “3.6.2” is “Python 3.6.x – Permission denied. I did download 3.6.2 and it is in my download folder but I am unable to copy or move it to /usr/src. I am new to Linux so it is undoutedly my inexperience that limits me but I would like to use Python on LinuxMint. Thanks.

        • Rahul Rahul K. Reply
          September 2, 2017 at 4:08 am

          Hi Don, Use sudo with cp command to copy files.

          • Avatar Don Reply
            September 2, 2017 at 3:42 pm

            Thanks. I was using the right click copy & paste to do it. The command line worked. Following the rest of the commands above it extracted and at the end of the ./configure task it indicated that if wanted a release build with all stable optimizations active (PGO, etc) I should run “./configure –enable-optimizations” which I did.

            After running the “sudo make altinstall” command I ran the “Python-3.6 -V” command and got “Command not found”. I cannot find v3.6.2 on the computer. I do find v 2.7.11 and v 3.5 .2. I also find “Idle” for v 2.7.

            I’ll give up on this for now and learn more about LinuxMint before trying again. I have previous experience in programming but trying to get Python 3.6.2 has me frustrated. Thanks.

            • Avatar Peter Henry
              September 8, 2017 at 8:12 pm

              You might have already figured this out, but in case you haven’t – your comment uses an incorrect binary name. You should be able to use the new version by running “python3.6” (so your version check would be “python3.6 -V”, not “Python-3.6 -V”). The rest of this comment is optional; only read if you want a pedantic breakdown of how python versions are managed.

              To paraphrase from the Python-3.6.2/README.rst file:

              >All files and installed using “sudo make altinstall” contain the major and minor version and can thus live side-by-side: “${prefix}/bin/pythonX.Y”.

              >”sudo make install” also creates the symbolic link “${prefix}/bin/python3” which points to “${prefix}/bin/pythonX.Y”.

              An example to illustrate what this means:

              Python 2.7.6 and Python 3.4.3 are installed by default on Ubuntu 14.04. If you run “python”, you enter a Python 2.7.6 prompt – because there is a symlink called “python” pointing to a symlink called “python2” pointing to a binary called “python2.7”. Running “python2” gives the same result, of course. If you run “python3”, you enter a Python 3.4.3 prompt – because there is a symlink called “python3” pointing to a binary called “python3.4”.

              If you follow this page’s instructions and use “make altinstall”, a new binary will be added called “python3.6” Running “python3.6” gives 3.6.2; running “python3.4” gives 3.4.3; running “python3” gives 3.4.3 (because of the symlink).

              If instead you use “make install”, the “python3.6” binary is created, same as before – but in ADDITION to this, the “python3” symlink will be overwritten with one that points to “python3.6”. So running “python3.6” and “python3.4” has the same behavior as before, but now running “python3” gives 3.6.2.

              By default in Ubuntu (and so probably in Linux Mint) the system python links/binaries are in the /usr/bin folder, and it seems like when a user installs Python from source, by default the links/binaries are put in /usr/local/bin.

              So if you’ve used the defaults, you can find most of what you have by running this command: “find /usr/bin /usr/local/bin -iname ‘python*’ -ls” (i.e., find everything in /usr/bin and /usr/local/bin whose name starts with “python” and print the results).

  38. Avatar Jonathan Groves Reply
    July 31, 2017 at 10:40 am

    Also works fine on Raspian Jessie 4.9.24 – thanks for sharing.

  39. Avatar IRSHAD C M Reply
    July 22, 2017 at 1:06 pm

    when iam installing python3.6.0,i wrote the command for downloading python version $ cd/usr/src but it showing that such directory was not existing,so what can i do

    • Avatar Mike Valentin Reply
      December 8, 2020 at 1:59 pm

      put a space after the “cd” command….you have “cd/usr/src” when it should be “cd /usr/src” – pay close attention to syntax as it will trip you up all the time….

  40. Avatar Jorge Ibarra Reply
    May 4, 2017 at 5:58 pm

    Hi. I needed to do: sudo wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz, then I untar but the terminal is not allowing me to cd to Python-3.6.0/ !!! “Permission denied”. If I try: sudo cd Python-3.6.0/ then “sudo: cd: command not found” 🙁 What can I do?

    • Avatar Abbas Moghtanei Reply
      May 16, 2017 at 12:43 am

      I had the same problem too. What I did was, I used “sudo -s”, and then I was able
      to cd to Python-3.6.0 .

  41. Avatar az Reply
    April 8, 2017 at 7:39 pm

    Hi
    How i can use python 3.6 as default in Ubuntu 16.04 ?

    • Avatar VaGNaroK Reply
      May 15, 2017 at 5:27 pm

      using this ppa for ubuntu and derivates 14.04/16.04:

      ppa:jonathonf/python-3.6

  42. Avatar Madao Reply
    April 4, 2017 at 3:51 am

    thanks 🙂

  43. Avatar Aikya Reply
    March 16, 2017 at 8:28 pm

    Hi Rahul,
    Python 2.7 was pre -installed on my laptop. I use Ubuntu 16.04

    I downloaded 3.6.0 and followed the steps mentioned by you.
    I encountered no error in any of the steps.
    Yet the version still shows 2.7.

    Help needed. Thanks
    Aikya

    • Rahul Rahul K. Reply
      March 17, 2017 at 9:48 am

      Hi Aikya,

      The command will be as python3.6 not only python

      $ python3.6
      

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy