1. 下载
# 我下载到了 /tmp 目录中
cd /tmp
wget 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.0
sudo ./configure
sudo make
sudo make install
4. 修改默认的python为新安装的3.6
# 备份原有的,并新建新的软链
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
# pip也修改一下
mv /usr/bin/pip /usr/bin/pip.bak
ln -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