How to Install Python 3 on CentOS

Introduction

Python is a high level, dynamic, general purpose language. It was developed by Guido Van Rossum in 1991. Python's syntax allows developers to use fewer lines of code than any other programming language. It basically focuses on the code readability of program. Python 2.7 is installed by default on CentOS but we can install other versions like Python 3.5 and 3.6. In this tutorial, we are learning how to install Python 3.6.3 on CentOS.

Prerequisites

  • CentOS
  • Login as an administrator on the terminal
  • Yum must be configured on the system.

Installation

Installation includes following steps.

1. Install IUS community Repository

In order to install Python 3.6 on CentOS, we need to first install IUS community repository which provides extra packages for Enterprise Linux. Execute the following command to install IUS community repository.

CentOS How to Install Python 3 on CentOS

2. Install Python 3

Execute the following command to install python 3.6 on CentOS.

CentOS How to Install Python 3 on CentOS 1

3. Verify Python

To verify if we have installed correct version of python, we just need to type python3.6 -V on the terminal. The command will show the version installed which is 3.6.4 in my case.

CentOS How to Install Python 3 on CentOS 2

4. Working on Python's script mode

Just type python3.6 on the terminal to enter the Python's script mode. We can execute the python statements on this shell. Since, python 2 is by default installed on CentOS, hence typing python on the terminal takes us to the python2 shell, hence we have to type python3.6 to work on the desired python shell.

CentOS How to Install Python 3 on CentOS 3

Execute the valid python statements which get interpreted and show the desired output on the terminal as shown below.

CentOS How to Install Python 3 on CentOS 4

Hence, we have installed and get started with Python 3.






Latest Courses