博主由于之前瞎搞真寻Bot的一键包,把自己腾讯云的Python环境搞崩了,所以本次就把整个系统的Python环境重新卸载了一遍,并进行了Python3.9.5版本的重装,特在此记录一下卸载和重装的命令。
一.卸载Python环境
由于Centos系统的yum命令需要使用到Python的环境,所以在卸载Python环境后,yum命令就无法使用了,所以这里我们再重装Python环境的同时,也要重装一下yum命令。
1.卸载Python环境
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装的Python及其关联
whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果
2.卸载系统yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum|xargs rm -fr
whereis yum
二.重装Python环境
1.重装Centos默认的Python环境
这一步并非安装Python3.9.5,而只是把系统之前自带的Python环境给安装回去
mkdir /home/rpm && cd /home/rpm #创建一个存放安装文件的文件夹,这样下载的东西下次还可以直接拿来用
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python2-rpm-macros-3-34.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-ipaddr-2.1.11-2.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-rpm-macros-3-34.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-srpm-macros-3-34.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
#在/home/rpm目录下安装对应的rpm包
rpm -Uvh --force --nodeps --replacepkgs *.rpm
更新yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2.重装Python3.9.5
mkdir /home/python3.9.5 && cd /home/python3.9.5
wget https://mirrors.huaweicloud.com/python/3.9.5/Python-3.9.5.tgz
# 下载 Python 源代码
# 官方源 : https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
tar -xf Python-3.9.5.tgz && cd Python-3.9.5
# 解压并进入文件夹
./configure
# 编译检查, 生成 Makefile
make&&make install
# 编译安装
pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 后面的-i参数的内容是用于国内机器的下载加速的
3.安装Python3.10.6的方法
https://blog.51cto.com/u_15478219/5791314参考这一blog的方法
Comments NOTHING