1. 下载
# 我下载到了 /tmp 目录中cd /tmpwget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
2. 安装依赖
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
3. 编译安装
cd Python-3.6.0sudo ./configuresudo makesudo make install
4. 修改默认的python为新安装的3.6
# 备份原有的,并新建新的软链mv /usr/bin/python /usr/bin/python.bakln -s /usr/local/bin/python3 /usr/bin/python# pip也修改一下mv /usr/bin/pip /usr/bin/pip.bakln -s /usr/local/bin/pip3 /usr/bin/pip
至此,Python3.6 就已经安装成功了
5. 修改一个yum使用的Python(yum暂不支持python3)
vim /usr/bin/yum# 修改声明的Python为2.x即可#!/usr/bin/python2.6