Table of Contents
In this article, I will take you through the steps to install python3 on CentOS 7.
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the GNU General Public License (GPL).
The steps to install python3 on CentOS 7 is fairly easy through yum tool.
Install Python3 on CentOS 7
Here are simple steps to install python3 on CentOS 7.
Update all the packages first
We first need to upgrade all the packages through yum to make sure all the dependent package is updated and installed.
[root@localhost ~]# yum update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net No packages marked for update
Install python3 package first
Once all the packages are updated,we can go ahead and install python3 package through yum install command.
[root@localhost ~]# yum install python3 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Resolving Dependencies --> Running transaction check ---> Package python3.x86_64 0:3.6.8-10.el7 will be installed --> Processing Dependency: python3-libs(x86-64) = 3.6.8-10.el7 for package: python3-3.6.8-10.el7.x86_64 --> Processing Dependency: python3-setuptools for package: python3-3.6.8-10.el7.x86_64 --> Processing Dependency: python3-pip for package: python3-3.6.8-10.el7.x86_64 --> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-10.el7.x86_64 --> Running transaction check ---> Package python3-libs.x86_64 0:3.6.8-10.el7 will be installed --> Processing Dependency: libtirpc.so.1()(64bit) for package: python3-libs-3.6.8-10.el7.x86_64 ---> Package python3-pip.noarch 0:9.0.3-5.el7 will be installed ---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed --> Running transaction check ---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: python3 x86_64 3.6.8-10.el7 base 69 k Installing for dependencies: libtirpc x86_64 0.2.4-0.16.el7 base 89 k python3-libs x86_64 3.6.8-10.el7 base 7.0 M python3-pip noarch 9.0.3-5.el7 base 1.8 M python3-setuptools noarch 39.2.0-10.el7 base 629 k Transaction Summary ======================================================================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 9.5 M Installed size: 48 M Is this ok [y/d/N]: y Downloading packages: (1/5): libtirpc-0.2.4-0.16.el7.x86_64.rpm | 89 kB 00:00:00 (2/5): python3-3.6.8-10.el7.x86_64.rpm | 69 kB 00:00:00 (3/5): python3-pip-9.0.3-5.el7.noarch.rpm | 1.8 MB 00:00:00 (4/5): python3-setuptools-39.2.0-10.el7.noarch.rpm | 629 kB 00:00:00 (5/5): python3-libs-3.6.8-10.el7.x86_64.rpm | 7.0 MB 00:00:01 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 5.4 MB/s | 9.5 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libtirpc-0.2.4-0.16.el7.x86_64 1/5 Installing : python3-setuptools-39.2.0-10.el7.noarch 2/5 Installing : python3-pip-9.0.3-5.el7.noarch 3/5 Installing : python3-3.6.8-10.el7.x86_64 4/5 Installing : python3-libs-3.6.8-10.el7.x86_64 5/5 Verifying : libtirpc-0.2.4-0.16.el7.x86_64 1/5 Verifying : python3-setuptools-39.2.0-10.el7.noarch 2/5 Verifying : python3-libs-3.6.8-10.el7.x86_64 3/5 Verifying : python3-3.6.8-10.el7.x86_64 4/5 Verifying : python3-pip-9.0.3-5.el7.noarch 5/5 Installed: python3.x86_64 0:3.6.8-10.el7 Dependency Installed: libtirpc.x86_64 0:0.2.4-0.16.el7 python3-libs.x86_64 0:3.6.8-10.el7 python3-pip.noarch 0:9.0.3-5.el7 python3-setuptools.noarch 0:39.2.0-10.el7 Complete!
Check if the python packages are installed or not using rpm tool
Once the package is installed, we need to check from rpm database and verify it once.
[root@localhost ~]# rpm -qa | grep -i python3 python3-setuptools-39.2.0-10.el7.noarch python3-3.6.8-10.el7.x86_64 python3-pip-9.0.3-5.el7.noarch python3-libs-3.6.8-10.el7.x86_64
Write your first Python Script
Now that our package is installed, Let’s go through a simplest script.
[root@localhost ~]# cat HelloWorld.py print("Hello World")
Run your HelloWorld Script and check the output
[root@localhost ~]# python3 HelloWorld.py
Hello World
Also Read: Perl Installation on CentOS 7
For more info on Python, Go to this link.
In the next article, i will take you through the steps to install Python3 on Ubuntu 18.08