python
#卸载python3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
#删除所有残余文件
whereis python3 |xargs rm -frv
#查看现有安装的python,验证是否删除干净
whereis python
# 安装依赖
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
# 下载安装包
# wget https://www.python.org/ftp/python/{version}/Python-{version}.tar.xz
# {version}指定版本号 3.9.7
wget "https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz"
# 解压
tar -zxvf Python-3.7.9.tgz
# 进入解压目录
cd Python-3.7.9
# 配置
./configure --prefix=/usr/local/python3
# 编译
make
# 安装
make install
# 建立软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3