Home » Python: Install Python on Linux – CentOS 7

Python: Install Python on Linux – CentOS 7

by Pring
Python: Install Python on Linux - CentOS 7

I. Introduction.

This tutorial will teaches you how to install Python on Linux – CentOS 7 system. Python is a high-level programming language, application in numerous areas: include web programming, scripting, scientific computing and artificial intelligence.
Python is processed at runtime by the interpreter.

Python have major versios of Python are 1.x, 2.x and 3.x
Code written for Python 3.x is guaranteed to work in all future versions.

An interpreter is a program that runs scripts written in an interpreted language as Python.

II. Prerequisites.

1.  Login to your system via SSH. You can use PuTTy tool or Poderosa tool,…
2.  Login with root user.  If you are logged in as another user, you will need to add sudo before each command.

III. Install Python on CentOS 7 by step by step.

To install Python on Linux – CentOS 7. Follow these steps:
1. Add repository to your system.
2. Update yum to finish adding the repository.
3. Install Python.
4. Testing the Installation.

You can see details of Video on How to Install Python on Linux – CentOS 7 as below.
[Sorry, the video we will update later]

Or you also can see details as below.

Step 1. Add repository to your system.

Enter command below:

sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm

Sample Output:

[root@devopsio ~]# sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
ius-release.rpm                                                         | 8.2 kB  00:00:00     
Examining /var/tmp/yum-root-TGq5Ho/ius-release.rpm: ius-release-2-1.el7.ius.noarch
Marking /var/tmp/yum-root-TGq5Ho/ius-release.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package ius-release.noarch 0:2-1.el7.ius will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                Arch              Version                Repository               Size
===============================================================================================
Installing:
 ius-release            noarch            2-1.el7.ius            /ius-release            4.5 k

Transaction Summary
===============================================================================================
Install  1 Package

Total size: 4.5 k
Installed size: 4.5 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ius-release-2-1.el7.ius.noarch                                              1/1 
  Verifying  : ius-release-2-1.el7.ius.noarch                                              1/1 

Installed:
  ius-release.noarch 0:2-1.el7.ius                                                             

Complete!

Step 2. Update yum to finish adding the repository.

Enter command below:

sudo yum update

Step 3. Install Python.

Enter command below:

sudo yum install -y python36u python36u-libs python36u-devel python36u-pip

Sample Output:

[root@devopsio ~]# sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
Resolving Dependencies
--> Running transaction check
---> Package python36u.x86_64 0:3.6.8-1.el7.ius will be installed
---> Package python36u-devel.x86_64 0:3.6.8-1.el7.ius will be installed
---> Package python36u-libs.x86_64 0:3.6.8-1.el7.ius will be installed
---> Package python36u-pip.noarch 0:9.0.1-1.ius.el7 will be installed
--> Processing Dependency: python36u-setuptools for package: python36u-pip-9.0.1-1.ius.el7.noarch
--> Running transaction check
---> Package python36u-setuptools.noarch 0:39.0.1-1.ius.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================
 Package                       Arch            Version                      Repository    Size
===============================================================================================
Installing:
 python36u                     x86_64          3.6.8-1.el7.ius              ius           58 k
 python36u-devel               x86_64          3.6.8-1.el7.ius              ius          841 k
 python36u-libs                x86_64          3.6.8-1.el7.ius              ius          8.9 M
 python36u-pip                 noarch          9.0.1-1.ius.el7              ius          1.8 M
Installing for dependencies:
 python36u-setuptools          noarch          39.0.1-1.ius.el7             ius          643 k

Transaction Summary
===============================================================================================
Install  4 Packages (+1 Dependent package)

Total download size: 12 M
Installed size: 55 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/ius/packages/python36u-3.6.8-1.el7.ius.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 4b274df2: NOKEY
Public key for python36u-3.6.8-1.el7.ius.x86_64.rpm is not installed
(1/5): python36u-3.6.8-1.el7.ius.x86_64.rpm                             |  58 kB  00:00:00     
(2/5): python36u-devel-3.6.8-1.el7.ius.x86_64.rpm                       | 841 kB  00:00:00     
(3/5): python36u-pip-9.0.1-1.ius.el7.noarch.rpm                         | 1.8 MB  00:00:00     
(4/5): python36u-setuptools-39.0.1-1.ius.el7.noarch.rpm                 | 643 kB  00:00:00     
(5/5): python36u-libs-3.6.8-1.el7.ius.x86_64.rpm                        | 8.9 MB  00:00:00     
-----------------------------------------------------------------------------------------------
Total                                                          8.0 MB/s |  12 MB  00:00:01     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
Importing GPG key 0x4B274DF2:
 Userid     : "IUS (7) <dev@ius.io>"
 Fingerprint: c958 7a09 a11f d706 4f0c a0f4 e558 0725 4b27 4df2
 Package    : ius-release-2-1.el7.ius.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python36u-libs-3.6.8-1.el7.ius.x86_64                                       1/5 
  Installing : python36u-3.6.8-1.el7.ius.x86_64                                            2/5 
  Installing : python36u-setuptools-39.0.1-1.ius.el7.noarch                                3/5 
  Installing : python36u-pip-9.0.1-1.ius.el7.noarch                                        4/5 
  Installing : python36u-devel-3.6.8-1.el7.ius.x86_64                                      5/5 
  Verifying  : python36u-3.6.8-1.el7.ius.x86_64                                            1/5 
  Verifying  : python36u-devel-3.6.8-1.el7.ius.x86_64                                      2/5 
  Verifying  : python36u-libs-3.6.8-1.el7.ius.x86_64                                       3/5 
  Verifying  : python36u-setuptools-39.0.1-1.ius.el7.noarch                                4/5 
  Verifying  : python36u-pip-9.0.1-1.ius.el7.noarch                                        5/5 

Installed:
  python36u.x86_64 0:3.6.8-1.el7.ius            python36u-devel.x86_64 0:3.6.8-1.el7.ius      
  python36u-libs.x86_64 0:3.6.8-1.el7.ius       python36u-pip.noarch 0:9.0.1-1.ius.el7        

Dependency Installed:
  python36u-setuptools.noarch 0:39.0.1-1.ius.el7                                               

Complete!

Step 4. Testing the Installation.

1. Check Python version. Enter command below:

python –version

Sample Output:

[root@devopsio ~]# python --version
Python 2.7.5

2. First Program.

Enter command below:

python
print(“HelloWorld!”);
exit();

Sample Output:

[root@devopsio ~]# python
Python 2.7.5 (default, Jun 20 2019, 20:27:34) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("HelloWorld!")
HelloWorld!
>>> exit();
[root@devopsio ~]#

IV. Conclusion.

In this tutorial, we’ve installed Python on CentOS 7 server. To learn more about using Python, this guide to learning more about Python.
You might want to check the following guides:


Install Python on CentOS 7 is complete. Wish you success and luck.
Thanks and best regards!
— Pring —

Related Articles

Leave a Comment