To check if you have python3 installed in CentOS 7 (which by default is not possible, as the latest version delivered is 2.7.5) you can run the command:


This will give you an error and says that you should try the python command, and this command will show you the python 2.7.5 result.

We will install the latest stable version of Python 3 in CentOS 7. This version, at the time of writing is 3.6.4.

First, run the following commands:

sudo yum update
sudo yum install yum-utils
sudo yum install wget

And then make sure to have all the dependencies needed (like GCC and others) by running the commands:

sudo yum install gcc openssl-devel
sudo yum groupinstall "development tools"

Now we will download python 3.6.4 from the following address and we will save it inside /usr/src directory:

cd /usr/src
sudo wget

Now we will extract the package with the command:

sudo tar -xvf Python-3.6.4.tar.xz

After the package has been decompressed, go to the directory with the command:

cd Python-3.6.4

And then install Python 3.6.4 with the following command:

sudo ./configure --prefix=/opt/python3

To install this version of Python, you will need to use the make altinstall command, in order to overcome problems that would be generated if you use the usual make install command.

sudo su
make && make altinstall

After that create a symbolic link from the python3.6 file to the /usr/bin/python3 command (python3.6 command already exists inside /usr/bin and you can use it, but I thought that python3 is more appropriate):

ls /usr/bin/python3.6
sudo ln -s /opt/python3/bin/python3.6 /usr/bin/python3

To check the installation, run the command:


This will output something like the following:

$ python3
Python 3.6.4 (default, Feb 27 2018, 22:19:46) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.

You can also run the python3.6 command, and you will get the same result as with python3.

This means that your Python 3 has been installed.

After you install Python 3, you will need to install some Python libraries, needed for development. Those extra packages will be installed from the IUS repository, as shown previously in a different article. For this, we need the python36u-devel package. Also, we will install pip the utilitary that you will use to install specific python packages.

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

You can also install the python36u-tools and tk-devel packages:

sudo yum install python36u-tools
sudo yum install tk-devel

To start the Python IDLE for Python 3.6, just run the command:

idle3.6 &

Happy coding!

idle36 The IDLE environment in CentOS7