一.下载源码包

地址https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz

二.解压源码包

1.下载解压工具xz
 #yum -y install search xz

2.解压
 #xz -d Python-3.6.3.tar.xz
 #tar -xf Python-3.6.3.tar

三.安装依赖文件

yum -y install zlib-devel  gcc

四.安装

cd Python-3.6.3

./configure --prefix=/usr/local/python

make && make install

五.后续工作

# which python
/usr/bin/python

#rm -rf /usr/bin/python       #删除原python软连接

#ln -s /usr/local/python/bin/python3 /usr/bin/python   #建立新的软连接

# python  
Python 3.6.3 (default, Dec 20 2017, 00:21:48)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>

完成

05-11 20:47