Centos7——yum与python重装问题及解决方法

在centos系统下yum命令出错,可能我们就要重新安装,当python的版本升级或安装了多个python版本时,就会导致No module named yum错误。一般的解决方法都是全部删除python和yum,然后进行重装。安装过程有可能会出现python(abi) is needed等问题。

下载需要的资源:
安装包下载:http://www.rpmfind.net/
网易yum资源安装包:http://mirrors.163.com/centos/7/atomic/x86_64/Packages/
centos资源安装包:http://mirrors.aliyun.com/centos/
python资源安装包:https://centos.pkgs.org/

根据自己要系统和要求进行下载

使用的环境
Centos7.4
Python2.7.5

第一步:卸载python和卸载yum
卸载python 方法一:

rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
whereis python|xargs rm -fr

卸载python 方法二:

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
whereis python |xargs rm -frv 	##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python 					##验证删除,返回无结果

卸载yum 方法一:

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
whereis yum|xargs rm -fr

卸载yum 方法二:

rpm -qa|grep yum|sudo xargs rpm -ev –allmatches –nodeps
whereis yum |sudo xargs rm -frv

第二步下载安装包:
下载Python相关库和依赖关系安装包:

wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/dbus-python-devel-1.1.1-9.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-86.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm

下载yum安装包:

wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm

首要执行: rpm -ivh python-* rpm-python-*
没有安装错误进行yum安装
执行:rpm -ivh yum-*

如果不行进行配置Python,再进行安装
下载Python安装包:

wget https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz

编译:

tar zxvf Python-2.7.5.tgz
cd Python-2.7.5
./configure
make && make install

然后做下软连接

ln -sf /usr/local/bin/python /usr/bin/python

查看python版本 Python -V

最后输入命令检测yum是否安装成功
没有错误安装完成

查阅问题处理

##问题一
error: Failed dependencies:
	rpm = 4.11.3-40.el7 is needed by rpm-libs-4.11.3-40.el7.x86_64
##修复处理-下载包
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm
##无视重新安装
rpm -Uvh rpm-4.11.3-40.el7.x86_64.rpm --nodeps --force

############################
##问题二
required to run yum. The error leading to this problem was:
   /usr/lib64/python2.7/site-packages/rpm/_rpm.so: undefined symbol: rpmtsAddReinstallElement
##修复处理-下载包
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-sign-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-build-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm
##无视重新安装
rpm -Uvh --replacepkgs *.rpm --nodeps --force

别的方法:
https://www.cnblogs.com/xdjun/p/11770418.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值