1.安装依赖包
yum install gcc openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel tk-devel wget curl-devel
2.下载python压缩包
curl -o https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
3.解压文件
tar xf Python-3.6.0.tgz
4.进入Python-3.6.0,编译安装
cd Python-3.6.0
./configure
#或者
#./configure --prefix=/usr/local/python3
make
sudo make install
5.使用python3作为默认版本
sudo vim /etc/profile.d/python.sh
编辑文件如下
alias python='/usr/local/bin/python3.6'
设置权限
chmod 755 /etc/profile.d/python.sh
重启会话使其生效
source /etc/profile.d/python.sh