Installing python3 has always been a bit of a pain on CentOS, particularly if you want a functioning pip3 alongside it.
I have experimented with RPMs from SCL and EPEL as well as installing from source, and had settled on installing the Python 3.4 RPM from EPEL as a good compromise of a reasonably recent version, and semi-regular patch updates.
In December 2017 EPEL released Python 3.6 (epel-announce link) but it isn’t obvious how to get it fully set up. Even Stack Overflow let me down. So I’m documenting it here.
For now I am using the following commands – use sudo before each one if you are running as a non-root user.
# Enable EPEL if required yum install epel-release # Install Python 3.6 yum install python36 # Install Pip from the RPM's internal "ensurepip" module python3.6 -m ensurepip# Create a symlink so it can be called using python3 ln -s /usr/bin/python3.6 /usr/bin/python3# Symlink pip3 into /usr/bin for consistency and ease of use with sudo ln -s /usr/local/bin/pip3 /usr/bin/pip3
You should now have functioning python3 and pip3:
$ pip3 install boto3 Collecting boto3 [...] Successfully installed boto3-1.8.3 $ python3 Python 3.6.5 (default, Jul 25 2018, 21:22:33) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license" for more information.
The announcement implied that at some point python36 will become the main Python 3 RPM in EPEL. I will try to update this post if/when that happens.
As of 4 April 2019, python36 is the main Python 3 RPM in EPEL, and contains the /usr/bin/python3 symlink so you no longer need to create it manually.