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

How to Install Python 3.6 on CentOS/RHEL 7/6 & Fedora 30/29

Written by Rahul, Updated on May 23, 2020

Python is a powerful programming language. It is very friendly and easy to learn. At writing time of this article Python 3.6.10 latest stable version is available to download and install. This tutorial will help you to install Python 3.6.10 on your CentOS, Red Hat & Fedora operating systems.

1. Requirements

This Python installation required GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.

yum install gcc openssl-devel bzip2-devel sqlite-devel
  • Read: How to Use SSH to Connect Remote Linux Server

2. Download Python 3.6

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

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

Now extract the downloaded package.

tar xzf Python-3.6.10.tgz

3. Install Python 3.6

Use below set of commands to compile Python source code on your system using altinstall.

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

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

Now remove downloaded source archive file from your system

rm /usr/src/Python-3.6.10.tgz

4. Check Python Version

Check the latest version installed of python using below command.

python3.6 -V

Python 3.6.10

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..

26 Comments

  1. Avatar maxmoon Reply
    January 17, 2020 at 3:42 pm

    How to remove old Python installations like this?
    Since Python 3.3 I try to get the newest version of Python3 in CentOS6 with this method.
    Now I have a system which has Python 3.3, 3.4 … 3.9 and between installed, but I don’t need all of them.
    Is there a save way to uninstall those again?

    P.S.: reCAPTCHA is a huge NO-GO!

    • Avatar ffauchille Reply
      February 7, 2020 at 3:30 pm

      I guess you could just remove the /usr/bin/python binary by a symlink to python3.6:

      rm /usr/bin/python
      ln -s /usr/local/bin/python3.6 /usr/local/bin

      • Avatar ffauchille Reply
        February 7, 2020 at 3:32 pm

        Sorry for the typo, here is the good one:

        rm /usr/bin/python
        ln -s /usr/local/bin/python3.6 /usr/bin/python

  2. Avatar Kausik Reply
    October 15, 2019 at 6:08 am

    This worked like charm.
    For RHEL 7.4, python 3.6, I later started getting ‘ModuleNotFoundError’ for ‘import nltk’.
    The reason is that sqlite3 wasn’t compiled properly.
    I installed sqlite-devel and recompiled python 3.6 – which had the issue fixed.
    yum install sqlite-devel
    /usr/src/Python-3.6.9 #Had the src already downloaded and extracted here
    ./configure –enable-optimizations
    make altinstall

  3. Avatar Darwin Reply
    September 20, 2019 at 11:59 pm

    Thank you for the notes.
    Installed on a barebones RHEL7.7, during the make altinstall step I got the error
    ModuleNotFoundError: No module named ‘_ctypes’
    make: *** [altinstall] Error 1
    Installed the package libffi-devel and it worked perfectly.
    Known bug – https://bugs.python.org/issue31652

  4. Avatar SRIRAM.V Reply
    April 30, 2019 at 10:41 am

    Thank you Rahul , this worked great for RHEL , no one seemed to have this Documented well anywhere else.

  5. Avatar waketzheng Reply
    March 27, 2019 at 10:55 am

    It worked for centos6. Thanks~

  6. Avatar Brian Reply
    March 16, 2019 at 7:01 pm

    thank you sir

  7. Avatar Rob T. Reply
    August 16, 2018 at 12:59 pm

    For most people, building Python from source isn’t good advice. Look through the comments that are already here.

    1 – There is no uninstal command, you are manually making changes to your system as root.
    2 – The dependency list to get all of the standard library modules (SSL, compression, database, etc. ) is long. See the above comments. Check one of the source RPMs for a full list of the packages that should be pre-installed. The details aren’t easy to get right. That’s why we have rpm and yum.
    3 – If you accidentally run ‘make install’ as root, you will likely break yum and other system admin utilities. This is tricky to recover from.
    4 – If there are bugs/security vulnerabilities in any of the underlying libraries, how will you know when you need to patch and rebuild your personal python build?
    5 – For companies that are using RHEL, there is usually an expectation of support from Red Hat. You can get a supported Python 3 from Red Hat via Software Collections. If you install from source, you are completely on your own.

  8. Avatar Deepak Reply
    July 4, 2018 at 5:32 am

    I want to install some python 3.6 packages with yum command without using pip so where can I get the required repository for it ?

  9. Avatar Kvark Reply
    May 16, 2018 at 1:08 pm

    having same issue, not found, fied by:
    # PATH=”/usr/local/bin:$PATH”

    also will be good to add aliases, add these to your .bashrc:
    alias python3=’/usr/local/bin/python3.5′
    alias pip3=’/usr/local/bin/pip3.5′
    # (without this sudo does not see aliases)
    alias sudo=’sudo ‘

  10. Avatar JK Reply
    May 13, 2018 at 3:12 am

    Thank you!

    Later, when I wonder other things, Can I ask you??
    I’m a junior developer..

  11. Avatar Riad Reply
    April 2, 2018 at 7:14 pm

    Thanks a lot ….

  12. Avatar Sridhar Reply
    March 28, 2018 at 5:13 pm

    Thanks Rahul.

    These instructions were helpful to me in installing Python 3.6 as a separate installation on top of current python 2.6 on Redhat 6

  13. Avatar Andrew Reply
    November 23, 2017 at 6:53 am

    PIP fails when i run pip to install a package I get “ImportError: cannot import name ‘main'”

    • Rahul Rahul K. Reply
      November 23, 2017 at 7:08 am

      Hi Andrew, I have successfully installed modules with pip3.6.

      $ pip3.6 install pypiHello

      Collecting pypiHello
      Downloading pypiHello-1.2.zip
      Installing collected packages: pypiHello
      Running setup.py install for pypiHello … done
      Successfully installed pypiHello-1.2

  14. Avatar Eli Boyarski Reply
    November 22, 2017 at 12:10 pm

    This method builds a python executable without ssl support and without bz2 support.
    Install openssl-devel and bzip2-devel before running configure.

    Also, run “configure –enable-optimizations” to get standard optimizations.

    Lastly, you may want to add some useful symlinks after installation, mapping e.g. pip3.6 to pip3, python3.6 to python3, etc..

    • Rahul Rahul K. Reply
      November 23, 2017 at 4:28 am

      Thanks Eli, I have updated our tutorial as per your suggestions

  15. Avatar krishna Reply
    October 24, 2017 at 8:27 am

    #cd Python-3.6.1
    No such file or directory

  16. Avatar GW Reply
    July 27, 2017 at 5:41 pm

    Could you please specify which, if any operation is to be done as root?
    Thanks!

  17. Avatar Tom Reply
    May 22, 2017 at 5:58 pm

    I get “zipimport.ZipImportError: can’t decompress data; zlib not available” when doing “make altinstall”. I know zlib is installed because “yum install zlib” gives me “Package zlib-1.2.7-17.el7.x86_64 already installed and latest version”

    • Avatar Nash Reply
      October 6, 2017 at 4:11 pm

      yum install zlib-devel will solve the zlip error.

  18. Avatar alp Reply
    May 3, 2017 at 12:41 am

    And how can I remove Python 3.6 after these instructions?
    I use Spyder and this software didn’t recognize Py 3.6 (only its version 3.5).
    Thanks in advance

  19. Avatar Dk Reply
    April 25, 2017 at 12:17 am

    I follow step by step and always get the error: python3.6: command not found

    • Avatar Baard Helmen Reply
      May 9, 2017 at 1:15 pm

      Try to use: python3

      • Avatar Tyler Reply
        July 26, 2017 at 6:11 pm

        Also, ensure that /usr/local/bin is in your PATH.

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy