How to install Python3 in Centos7

Centos7 comes with Python2 by default. This article explains the steps to install Python3 in Centos7.

Step1: Login to the server via ssh as root.

Step2: Install the dependency packages.

#yum install gcc openssl-devel bzip2-devel libffi-devel -y

Step3: Download the Python3 package.


Step4: Extract the downloaded package.

#tar -xvf Python-3.8.1.tgz

Step5: Change the location to the extracted folder.

#cd Python-3.8.1

Step6: Compile and install Python3.

#./configure --enable-optimizations
#make altinstall

Please note that "make altinstall" is used to prevent replacing the default python binary file "/usr/bin/python".

Now the newly installed Python will be accessible through the command "python3.8".

That's alll…