Install python 3.6 on Centos 6

#Introduction

OS Centos 6 the default python version 2. How to Install python 3.6 on Centos 6.

Installation packages pre-requisites

sudo yum -y install gcc openssl-devel bzip2-devel wget

Install python 3.6

cd /tmp/
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
tar xzf Python-3.6.6.tgz
cd Python-3.6.6
./configure --enable-optimizations
sudo make altinstall

Create symbolic link

sudo ln -sfn /usr/local/bin/python3.6 /usr/bin/python3.6

Python verifying new version.

[huupv2@server1 ~]$ python -V
Python 3.6.6

The result python 3.6 on centos 6.

[huupv2@server1 ~]$ cat /etc/redhat-release
CentOS release 6.5 (Final)
[huupv2@server1 ~]$ ll /usr/bin/python*
-rwxr-xr-x 2 root root 4864 Aug 18  2016 /usr/bin/python
lrwxrwxrwx 1 root root    6 Jul 19  2018 /usr/bin/python2 -> python
-rwxr-xr-x 2 root root 4864 Aug 18  2016 /usr/bin/python2.6
lrwxrwxrwx 1 root root    9 Mar  8 13:26 /usr/bin/python3 -> python3.4
-rwxr-xr-x 2 root root 6088 Oct  5  2019 /usr/bin/python3.4
-rwxr-xr-x 2 root root 6088 Oct  5  2019 /usr/bin/python3.4m
lrwxrwxrwx 1 root root   24 Mar  8 14:45 /usr/bin/python3.6 -> /usr/local/bin/python3.6

Configure alias python on .bashrc file

[huupv2@server1 ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
alias python='/usr/bin/python3.6'

Check python version 3.6 on centos 6

[huupv2@server1 ~]$ python
Python 3.6.6 (default, Mar  8 2021, 14:41:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[huupv2@server1 ~]$

Conclusion

You have Install python 3.6 on Centos 6. I hope will this your helpful. Thank you for reading the DevopsRoles page!

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.