Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Install Python 3.6 on Ubuntu & LinuxMint

    How to Install Python 3.6 on Ubuntu & LinuxMint

    By RahulMay 23, 20202 Mins Read

    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.

    Advertisement

    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)
    

    Install python Python Python3 Python3.6
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    What are the Python Static Variables

    Modulus Operator (%) in Bash

    Using Modulus Operator (%) in Bash

    Calculate Remainder in Bash

    How to Calculate Remainder (%) of a Division in Bash

    View 56 Comments

    56 Comments

    1. Bharath on May 18, 2021 3:29 am

      Thanks. This helped me.

      Reply
    2. Mike Valentin on December 8, 2020 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!!

      Reply
    3. Eric D. Rust on December 28, 2019 3:33 pm

      Thank you , excellent instruction

      Reply
    4. Jorge on November 1, 2019 11:59 pm

      Thanks god work!!

      Reply
    5. Philippe on July 17, 2019 8:56 am

      Thank you, it works well!

      Reply
    6. Aidan on June 25, 2019 4:15 pm

      Does this work on Raspberry Pi 3 B+?

      Reply
    7. haftom on April 22, 2019 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.

      Reply
      • rnickle on May 30, 2019 8:07 pm

        Did you ever find a resolution to this?

        Reply
    8. popzzy on April 1, 2019 8:54 pm

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

      Reply
    9. Dogo on March 15, 2019 7:14 am

      Thanks a bunch! Worked like a charm

      Reply
    10. Susi Juniastuti on January 16, 2019 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

      Reply
    11. Rachel on October 30, 2018 3:55 pm

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

      Reply
    12. Mahendra on September 22, 2018 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?

      Reply
    13. Last_Samurai on September 7, 2018 3:14 pm

      Thank’s very much brother!!!

      Good luck!!

      Reply
    14. Ömer yalçın on July 29, 2018 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.

      Reply
    15. Barrowman on July 1, 2018 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.

      Reply
    16. Doc on June 17, 2018 9:16 pm

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

      Reply
    17. Satish on May 7, 2018 4:25 am

      Nice but did not mention how to run python after installation

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

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

        Reply
    18. nico on April 14, 2018 3:58 am

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

      Reply
    19. buy moko on April 4, 2018 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?

      Reply
    20. Marco Korb on March 29, 2018 4:17 pm

      Thanks

      Reply
    21. sharath on March 27, 2018 11:00 am

      Thanks brother

      Reply
    22. Shawn on March 26, 2018 10:11 pm

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

      Reply
    23. Diego Misael Blanco Murillo on March 4, 2018 9:17 pm

      Thank you bro.

      Reply
    24. Himanshu on March 4, 2018 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 🙂

      Reply
    25. AM on February 28, 2018 2:57 pm

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

      Reply
    26. Sky on February 22, 2018 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.

      Reply
    27. Bob on February 16, 2018 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?

      Reply
    28. Spork on January 30, 2018 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.

      Reply
    29. Sander on January 24, 2018 3:16 pm

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

      Reply
      • Mister on February 5, 2018 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.

        Reply
    30. James Peres on January 13, 2018 1:13 pm

      thanks for your text!

      Reply
    31. Martin Taylor on January 12, 2018 10:13 pm

      Very helpful article, thanks

      Reply
    32. Jesse on January 9, 2018 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

      Reply
    33. Hiago on January 9, 2018 1:55 am

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

      Reply
    34. Shayne on January 1, 2018 12:46 pm

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

      Reply
    35. kishore on September 21, 2017 3:59 am

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

      Reply
    36. sanjana on September 15, 2017 8:46 am

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

      Reply
    37. Bhasha on September 1, 2017 7:41 am

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

      Reply
    38. Paul on August 29, 2017 3:04 pm

      It works with a little modifications. Thx a lot!

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

        Hi Paul,

        What modifications you did? Please share with our readers.

        Reply
        • Don on September 2, 2017 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.

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

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

            Reply
            • Don on September 2, 2017 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.

              Reply
              • Peter Henry on September 8, 2017 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).

    39. Jonathan Groves on July 31, 2017 10:40 am

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

      Reply
    40. IRSHAD C M on July 22, 2017 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

      Reply
      • Mike Valentin on December 8, 2020 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….

        Reply
    41. Jorge Ibarra on May 4, 2017 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?

      Reply
      • Abbas Moghtanei on May 16, 2017 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 .

        Reply
    42. az on April 8, 2017 7:39 pm

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

      Reply
      • VaGNaroK on May 15, 2017 5:27 pm

        using this ppa for ubuntu and derivates 14.04/16.04:

        ppa:jonathonf/python-3.6

        Reply
    43. Madao on April 4, 2017 3:51 am

      thanks 🙂

      Reply
    44. Aikya on March 16, 2017 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

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

        Hi Aikya,

        The command will be as python3.6 not only python

        $ python3.6
        
        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Configure Postfix to Use Gmail SMTP on Ubuntu & Debian
    • PHP Arrays: A Beginner’s Guide
    • Deploying Flask Application on Ubuntu (Apache+WSGI)
    • OpenSSL: Working with SSL Certificates, Private Keys and CSRs
    • How to Create and Read List in Python
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.