CentOS7重装yum和python

1.卸载现有的python 

  强制删除已安装程序及其关联

  rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps

  强制删除所有残余文件

  whereis python |xargs rm -frv

2.卸载现有的yum

  强制删除已安装程序及其关联

  rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps

  强制删除所有残余文件

  whereis yum |xargs rm -frv

 

下载与自己版本对应的rpm包

查看自己系统版本的命令:cat /etc/redhat-release

下载地址链接:http://mirrors.ustc.edu.cn/centos/ CentOS7.5的rpm包:

http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/ 我下载的rpm包,

如果在安装过程中提醒你有被依赖的,你可以

以下26个安装包从上往下用 rpm -ivh 逐个安装,如: rpm -ivh libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

(如遇warning: yum-3.4.3-161.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
类似异常,可在安装命令末尾追加:--force --nodeps 即可)

libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
python-2.7.5-68.el7.x86_64.rpm
python-backports-1.0-8.el7.x86_64.rpm
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
python-chardet-2.2.1-1.el7_1.noarch.rpm
python-devel-2.7.5-68.el7.x86_64.rpm
python-iniparse-0.4-9.el7.noarch.rpm
python-ipaddress-1.0.16-2.el7.noarch.rpm
python-kitchen-1.1.1-5.el7.noarch.rpm
python-libs-2.7.5-68.el7.x86_64.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-setuptools-0.9.8-7.el7.noarch.rpm
python-urlgrabber-3.10-8.el7.noarch.rpm
python-virtualenv-15.1.0-2.el7.noarch.rpm
rpm-4.11.3-32.el7.x86_64.rpm
rpm-build-4.11.3-32.el7.x86_64.rpm
rpm-build-libs-4.11.3-32.el7.x86_64.rpm
rpm-libs-4.11.3-32.el7.x86_64.rpm
rpm-python-4.11.3-32.el7.x86_64.rpm
rpm-sign-4.11.3-32.el7.x86_64.rpm
yum-3.4.3-158.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
yum-utils-1.1.31-45.el7.noarch.rpm

这两个包存在相互依赖,所以要区别对待同时安装:

命令: rpm -ivh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm 即可

yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
在库中下载同名的rpm包。 

如果安装完成后键入yum能有正常显示,就说明安装成功了。如果出现:

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   /usr/lib64/python2.7/site-packages/rpm/_rpm.so: undefined symbol: rpmpkgVerifySi

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq
表示rpm包没安装全

本文参考来自:https://blog.csdn.net/qq_36731677/article/details/83552436

 

修改源:(注意:以下操作为非必要操作,需换源才进行操作!)

使用官网的镜像

把/etc/yum.repos.d/下面所有的源给备份并清空这个文件夹

 

重新生成镜像:rpm -Uvh --force http://mirror.centos.org/centos-7/7/os/x86_64/Packages/centos-release-7-4.1708.el7.centos.x86_64.rpm

有如下文件即可:

  1. -rw-r--r--. 1 root root 1664 8月  30 23:53 CentOS-Base.repo  
  2. -rw-r--r--. 1 root root 1309 8月  30 23:53 CentOS-CR.repo  
  3. -rw-r--r--. 1 root root  649 8月  30 23:53 CentOS-Debuginfo.repo  
  4. -rw-r--r--. 1 root root  314 8月  30 23:53 CentOS-fasttrack.repo  
  5. -rw-r--r--. 1 root root  630 8月  30 23:53 CentOS-Media.repo  
  6. -rw-r--r--. 1 root root 1331 8月  30 23:53 CentOS-Sources.repo  
  7. -rw-r--r--. 1 root root 3830 8月  30 23:53 CentOS-Vault.repo  

生成缓存:

  1. yum clean all  
  2. yum makecache  

必要时进行:yum update

换源参考来自:https://qindongliang.iteye.com/blog/2404750

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值