1.手动安装
#安装gcc编译器
yum -y install gcc
#安装依赖包
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
#安装openssl
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz --no-check-certificate
#解压
tar -zxf openssl-1.1.1n.tar.gz
#进入预安装目录
cd openssl-1.1.1n
#编译、安装
./config --prefix=/usr/local/openssl
make && make install
#下载python安装包
#https://www.python.org/ftp/python/
#解压
tar -zxvf Python-3.x.x.tgz
#创建安装后文件目录
mkdir /usr/local/python3
#进入预安装文件
cd Python-3.x.x
#编译、安装
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-openssl-rpath=auto
make && make install
#建立软连接
ln -s /usr/local/python3/bin/python3.* /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.* /usr/bin/pip3
2.卸载
#卸载python3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
#删除所有残余文件
whereis python3 |xargs rm -frv
#查看现有安装的python,验证是否删除干净
whereis python