1、安装编译Python3的相关依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
2、安装python3
#下载源码
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
#解压并进入目录
tar -zxvf Python-3.7.0.tgz
cd Python-3.7.0
#生成MakeFile -prefix指定路径
./configure prefix=/usr/local/python3
#编译
make
make install
3、添加软链接
#添加python3的软链接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
#添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
#测试安装是否成功
[root@centos-linux Python-3.7.0]# python3 -V
Python 3.7.0
注意CentOS自带python2,所以软链接的时候如果想要链接成python而不是python3需要把原本的如软链接删除