centos7误删除python2.7导致的python和yum不可用处理

centos7误删除python2.7后导致yum不可用:

问题截图

centos7误删除python2.7导致的python和yum不可用处理

解决方法:

1、在opt目录下创建site_package/python3递归目录,然后下载以下RPM包,并存入/opt/site_package/python3目录中

http://vault.centos.org/7.5.1804/os/x86_64/Packages/lvm2-python-libs-2.02.177-4.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-libs-2.7.5-68.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-2.7.5-68.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/rpm-python-4.11.3-32.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-plugin-aliases-1.1.31-45.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm

http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

centos7误删除python2.7导致的python和yum不可用处理

2、执行下面的命令,安装python开头的RPM包

执行下面的命令

rpm -Uvh --replacepkgs python*.rpm

centos7误删除python2.7导致的python和yum不可用处理

3、删除原有yum源

rpm -aq|grep yum|xargs rpm -e --nodeps

centos7误删除python2.7导致的python和yum不可用处理

4、安装rpm-python起始, yum起始开头的RPM包

–force 即使覆盖属于其它包的文件也强迫安装

–nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装

rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --force --nodeps

centos7误删除python2.7导致的python和yum不可用处理

5、将yum源配置为阿里的开源镜像

备份原来的镜像源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.back

centos7误删除python2.7导致的python和yum不可用处理

6、下载阿里yum源

wget http://mirrors.aliyun.com/repo/Centos-7.repo

centos7误删除python2.7导致的python和yum不可用处理

将Centos-7.repo重命名为CentOS-Base.repo

centos7误删除python2.7导致的python和yum不可用处理

清除系统所有的yum缓存

yum clean all

centos7误删除python2.7导致的python和yum不可用处理

生成yum缓存

yum makecache

centos7误删除python2.7导致的python和yum不可用处理

7、安装epel源

yum install -y epel-release

centos7误删除python2.7导致的python和yum不可用处理

使用阿里开源镜像提供的epel源

wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo

centos7误删除python2.7导致的python和yum不可用处理

再次清除系统yum缓存,并重新生成新的yum缓存

yum clean all
yum makecache

查看系统可用的yum源和所有的yum源

yum repolist enabled

centos7误删除python2.7导致的python和yum不可用处理

8、现在可以正常使用python2.7了

centos7误删除python2.7导致的python和yum不可用处理

上一篇:ftk学习记(消息框篇)


下一篇:centos7下安装docker(19容器架构)