1、依赖环境安装
yum install -y wget lrzsz net-tools zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum install libffi-devel -y
2、查询python2版本路径并备份
whereis python
mv /usr/bin/python /usr/bin/python2
3、python3.9源码安装
cd /usr/local
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
mkdir python3.9
cd /usr/bin
cd Python-3.9.1/
./configure --prefix=/usr/local/python3.9
make
make install
4、python3创建软连接
ln -s /usr/local/python3.9/bin/python3 /usr/bin/python
ln -s /usr/local/python3.9/bin/python3 /usr/bin/python3
5、python加入PATH环境变量
vim /etc/profile
export PATH=/usr/local/python3.9:$PATH
source /etc/profile
6、解决yum不能用的问题
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
将#!/usr/bin/python改成#!/usr/bin/python2
6、安装pip3
yum -y install python3-pip
7、卸载Python3
1)卸载python3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
2)删除所有残余文件
whereis python3 |xargs rm -frv
成功卸载!
3)whereis python 查看现有安装的python