yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
2、改名Python
cd /usr/bin
mv python python2.bak
3、下载并安装python3
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar -xf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure prefix=/usr/local/python3
make && make install
4、建立软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python
5、修改yum与urlgrabber-ext-down的Python头
将#! /usr/bin/python修改为#! /usr/bin/python2
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
原文:https://blog.51cto.com/hongtengfei/2361764