How to Install Python 3 on CentOS 7
In This Tutorial We are going discuss How to Install python3 on CentOS 7 Linux.
For CentOS 7 We have two methods to Install Python 3. One Method is to use the epel software repository. Another method is to download and install python3 from the source.
Install Python3 using the fedora epel repository
CentOS 7 still uses python version 2 and version 3 is not included in CentOS 7 Base software Repository. But the good news is epel repository now provides python3 for CentOS 7. So if we install epel release, then we can install python3 using yum command.
yum install epel-release
Next, use yum search command to find what is the available python3 minor release.
yum search python3 | grep devel
Then, use yum install command to install python 3
yum -y install python34-devel.x86_64
Finally, make symlink to point /usr/bin/python3 to /usr/bin/python3.4
ln -s /usr/bin/python3.4 /usr/bin/python3
Compile and install python 3 from the source
This is the Second method. First, go to following URL www.python.org/downloads/source/ and download the latest python3 release.
Download either XZ compressed source tarball or Gzipped source tarball, No Different.(As above image shows, version 3.5.1 was the latest release at the time I write this article.)
Extract the tar file using the tar command. for XZ compressed source tarball execute.
tar -Jxvf Python-3.5.1.tar.xz
If you downloaded the Gzipped source tarball, then execute
tar -zxvf Python-3.5.1.tgz
Now move into the extracted folder using cd command.
cd Python-3.5.1
And finally execute the following commands one by one to install python3 on CentOS 7.
./configure
make
make test
sudo make install
Each command could take a few minutes to complete. once finished, you can type python3 on the terminal to get python 3 interpreter.
As you can see both methods are very easy. But I would recommend to use the method one, which is to use epel repository and yum command. Because yum command search and install all the dependencies needed to run a software. So always try to use yum command to install software on CentOS 7, whenever possible.