1)环境准备
(1)查看python版本
[root@node1 ~]# python -V
Python 2.7.5
(2)安装GCC与wget
[root@node1 ~]# yum install gcc gcc-c++
[root@node1 ~]# yum install wget
(3)安装xz工具
[root@node1 ~]# wget http://down1.chinaunix.net/distfiles/xz-5.0.3.tar.bz2
[root@node1 ~]# tar -xjvf xz-5.0.3.tar.bz2
[root@node1 ~]# cd xz-5.0.3
[root@node1 xz-5.0.3]#./configure
[root@node1 xz-5.0.3]# make
[root@node1 xz-5.0.3]# make install
2)安装Python3.6.5
(1)下载解压Python安装包
[root@node1 ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
[root@node1 ~]# xz -d Python-3.6.5.tar.xz
[root@node1 ~]# tar -xvf Python-3.6.5.tar
尖叫提示:“tar -xJvf Python-3.6.5.tar.xz -C /opt/module/也可以解压
(2)编译安装Python
[root@node1 ~]# cd Python-3.6.5
[root@node1 Python-3.6.5]# ./configure
[root@node1 Python-3.6.5]# make && make install
(3)将系统指向的python从2.7.5修改到3.6.5版本
[root@node1 ~]# /usr/local/bin/python3.6.5 -V
[root@node1 ~]# mv /usr/bin/python /usr/bin/python.bak
[root@node1 ~]# ln -s /usr/local/bin/python3 /usr/bin/python
(4)将yum对python的引用重新指向python2.7.5(即:yum使用2.7.5,系统用3.6.5)
[root@node1 ~]# vim /usr/bin/yum
!/usr/bin/**python2**
(5)检查python版本,检查yum是否可用
[root@node1 ~]# python -V
[root@node1 ~]# yum list