1.查看系统信息
[root@localhost software]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@localhost software]# uname -r
2.6.32-504.el6.x86_64
2.查看已安装Python版本
[root@localhost software]# rpm -aq | grep python
python-meh-0.12.1-3.el6.noarch
python-ethtool-0.6-5.el6.x86_64
python-decorator-3.0.1-3.1.el6.noarch
gnome-python2-gconf-2.28.0-3.el6.x86_64
at-spi-python-1.28.1-2.el6.centos.x86_64
python-markupsafe-0.9.2-4.el6.x86_64
gnome-python2-applet-2.28.0-5.el6.x86_64
gnome-python2-libwnck-2.28.0-5.el6.x86_64
python-2.6.6-52.el6.x86_64
libxml2-python-2.7.6-14.el6_5.2.x86_64
3.下载并编译安装要升级到的Python版本
下载地址
https://www.python.org/downloads/
./configure
make && make install
4、将系统默认的python版本设置为3.6.2
[root@localhost ~]# rm /usr/bin/python
[root@localhost ~]# ln -s /usr/local/bin/python3.6 /usr/bin/python
五、检查升级后的python版本
[root@localhost software]# python -V
Python 3.6.2
六.解决升级后yum源不能使用问题
#vim /usr/bin/yum
将#/usr/bin/python改为/usr/bin/python2.6保存后,执行
yum update
#yum update