by

How to install Python 2 and Python 3 on CentOS 8

Python is one of the most popular programming languages for computer programmers. It is so simple in syntax and easy for beginners to understand. Python is the best choice for developing simple to more complex applications.

By default Python is not installed on CentOS 8.0. If you need it, it will be installed. The most popular two versions of Python are available, Python 2 and Python 3. Python 2 is an old version that will expire in 2020, and Python 3 is the latest version used in many applications.  In the previous CentOS, an unversioned Python command was available by default, allowing users to easily set the default version of Python to their own preference. However, CentOS 8/RHEL does not have an unversioned Python standard command. This is because it prevents users from locking themselves to a particular version of Python. Therefore, CentOS 8.0 gives the user the choice to install and configure a particular version of Python according to their needs.

Features of the Python Programming Language

Some important features of Python are listed below

  • It is easy to learn and modify.
  • No need to program compilation and linking
  • It is portable, i.e. it can be operated on different hardware without changing the interface.
  • It is expandable and can add more low-level modules.
  • Scalable means that due to its good structure it also supports large applications.
  • Python has a system-wide, cross-platform library.
  • It supports testing and debugging in an interactive way.

The system manager tool YUM and DNF packages use Python in system libraries. In this article, you will learn how to install Python 2 and Python 3 on CentOS 8. Before you can begin installing Python 2 and Python 3, there are a few prerequisites that must be met.

Pre-requisites

  1. You must be login as the root user or you have Sudo command privileges.
  2. Basic knowledge of command-line Interface in Linux.

Python 2 installation

The following steps are involved to install Python 2 on CentOS 8.0:

Install yum updates

To ensure all packages are up to date in your system, the Yum package manager provides facility to CentOS 8 users to install all the latest updates related to software. For this purpose, run the following command:

$ sudo yum update

Update packages

Install python 2

After updating all Yum packages, install Python 2 on CentOS 8.0. Run the following command on the terminal to install Python 2:

$ sudo yum install python2

Install python 2

Verify installation of python 2

The installation of Python 2 has been completed. In Python 2 different types of versions are included. To know what Python version is installed on your system. Type the following command on terminal:

$ python2 --version

Check python 2 version

Here, Python 2.7.16 has installed on my CentOS 8.0 system.

Run Python 2

To verify the installation that Python 2 is installed on your system or not, run the following command on terminal:

$ python2

Run python2 interpreter

Python 2 has successfully installed on your system. By default, the python-pip package is also installed during Python 2 installation. So, now you should be able to work on Python packages.

Python 3 installation

Take the following steps to install Python 3 on CentOS 8.0.

Install yum updates

It is the best practice to keep the system packages up to date. So, again update all yum packages to run the following command:

$ sudo yum update

Install Python 3

Now, install Python 3 on CentOS 8.0. Run the following command on terminal:

$ sudo yum install python3

Install Python 3

Verify installation of python 3

To verify which version of Python 3 is installed on your system, type the following command on terminal:

$ python3 --version

Check Python 3 version

Run Python 3

After completing the installation of Python 3, you can check whether Python 3 is installed on your system correctly or not. Type the following command to run Python 3 on terminal:

$ python3

Run Python 3

Conclusion

In this tutorial, you learned about the installation of yum updates. More we have explored how to install Python 2 and Python 3 on CentOS 8.0.  I hope this article would be helpful for you. Now, I’m sure you would be able to install any type of version of Python on the CentOS 8 system.

Comment

Leave a Reply

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

News Feed