How to install Python on Centos 7

How to Install and Configure Python 3.6.3 On Centos 7

Nowadays, the programming languages development growth ​​to be more dynamic, object oriented, simple and interoperability has generated the robust frameworks for building an adaptive applications. One of the programming languages ​​that is being widely used today is Python. This article will discuss how to install Python on Centos 7 (how to install Python on Centos 7).

Python is a multipurpose interpretive programming language with a design philosophy that focuses on the level of code readability. Python is claimed to be a language that combines capabilities, with very clear code syntax, equipped with large standard and comprehensive library functionality. Python is also supported by a large community.

Python supports multiple programming paradigms, primarily; but not limited; on object-oriented programming, imperative programming, and functional programming. One of the features available in python is as a dynamic programming language that is equipped with automatic memory management. As with other dynamic programming languages, python is generally used as a scripting language, although in practice the use of this language more broadly covers the context of utilization which is generally not done using scripting languages. Python can be used for various software development purposes and can run on a variety of operating system platforms.

Python was developed by Guido van Rossum and currently under the Python Software Foundation is a non-profit organization formed as an intellectual copyright holder in Python. The latest stable version is Python version 3.8.0. which was released on October 14, 2019 .

Python 3.6.3 Installation

The Python installation article will be divided up to 5 section as described below :

At this section we will briefly discussing about how to install the Python 3.6 on Centos 7. By default Python 2.7.5 has been installed on CentOS 7. We have to enable the SCL (Software Collection) to have an access to the newer versions of programming languages and services which are not available in the core repositories. The SCL itself is a community project that allows you to build, install, and use multiple versions of software on the same system, without affecting system default packages.

Enable SCL (Software Collection)

As a prerequisite step, we have to update our CentOS 7 repository to the update ones, with sudo yum update command.

[ramans@localhost ~]$ sudo yum update

Installing CentOS SCL release file to enable the SCL by executing command yum install centos-release-scl.

[ramans@localhost ~]$ sudo yum install centos-release-scl
Loaded plugins: fastestmirror, langpacks
 Loading mirror speeds from cached hostfile
 Resolving Dependencies 

The execution result can be seen below :

how to Install python 3.6 on CentOS 7 - install and enable software collection

Install Python 3.6 Software

After enabling the SCL we have an access to SCL repository where the Python 3.6 exist. Then we install the Python 3.6, by executing sudo yum install rh-python36 command.

[ramans@localhost Downloads]$ sudo yum install rh-python36
Loaded plugins: fastestmirror, langpacks
 Loading mirror speeds from cached hostfile
 Resolving Dependencies
 --> Running transaction check
 ---> Package rh-python36.x86_64 0:2.0-1.el7 will be installed
 --> Processing Dependency: rh-python36-runtime for package: rh-python36-2.0-1.el7.x86_64
 --> Processing Dependency: rh-python36-python-virtualenv for package: rh-python36-2.0-1.el7.x86_64
 --> Processing Dependency: rh-python36-python-setuptools for package: rh-python36-2.0-1.el7.x86_64
 --> Processing Dependency: rh-python36-python-pip for package: rh-python36-2.0-1.el7.x86_64
 --> Processing Dependency: rh-python36-python for package: rh-python36-2.0-1.el7.x86_64
 --> Running transaction check
 ---> Package rh-python36-python.x86_64 0:3.6.3-7.el7 will be installed 
how to Install python 3.6 on CentOS 7. Install Python.
Python 3.6 Installation screen shot

We can verifty if the installation process was completed by checking the Python version, witch python --version command. But we will be prompted with the previous version Python 2.7.5, and we could enter the 3.6.3 environment by executing SLC command scl enable rh-python36 bash.

[ramans@localhost Downloads]$ python --version
Python 2.7.5
[ramans@localhost Downloads]$ scl enable rh-python36 bash
[ramans@localhost Downloads]$ python --version
Python 3.6.3
how to Install python 3.6 on CentOS 7. verify python version

Installing Python 3.6.3 Development Tools

The next step to complete our journey in Installing and configuring Python 3.6.3 is to prepare the development tools. By installing this package we made the Python modules creation tools. The command for this purpose is sudo yum groupinstall 'Development Tools'.

[ramans@localhost Downloads]$ sudo yum groupinstall 'Development Tools'
[sudo] password for ramans: 
Loaded plugins: fastestmirror, langpacks
how to Install python 3.6 on CentOS 7, iinstall development tools
install Development tools Python 3.6.3

Preparing Virtual Environment

In making a project in Python we are recommended to prepare a separate project environment for a project, so there is no mixing enviroment of one project with another. At this example, I have created a new mountpoint for this purpose, named as /data01.

/dev/mapper/vgdata01-lvdata01   10G   33M   10G   1% /data01

The projects environment will be under /data01 mountpoint. I created new directory as rapik_prj.

[root@localhost my_python_prj]# cd /data01
[root@localhost data01]# mkdir rapik_prj
[root@localhost data01]# cd rapik_prj/
[root@localhost rapik_prj]# pwd
[root@localhost rapik_prj]# python -m venv my_env_project
[root@localhost rapik_prj]# ls -ltr
total 0
drwxr-xr-x. 5 root root 74 Nov  8 23:22 my_env_project
[root@localhost rapik_prj]# source my_env_project/bin/activate
(my_env_project) [root@localhost rapik_prj]# 
how to Install python 3.6 on CentOS 7, preparing engvironment.

Sof far, the Python 3.6.3 installation and configuration has been done, we can deliver it to the development team.

Have a nice day… !

Share this article via :

Leave a Reply

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