https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/
# Start by making sure your system is up-to-date:
yum update
# Compilers and related tools:
yum groupinstall-y”development tools”
# Libraries needed during compilation to enable all features of Python:
yum install-yzlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel
# If you are on a clean “minimal” install of CentOS you also need the wget tool:
yum install-ywgetwget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
tar xf Python-2.7.14.tar.xz
cdPython-2.7.14
./configure–prefix=/usr/local–enable-unicode=ucs4–enable-shared LDFLAGS=”-Wl,-rpath /usr/local/lib”
make&&makealtinstall
wget https://bootstrap.pypa.io/get-pip.py# Then execute it using Python 2.7 and/or Python 3.6:
python2.7 get-pip.py# With pip installed you can now do things like this:
pip2.7 install [packagename]
pip2.7 install –upgrade [packagename]
pip2.7 uninstall [packagename]