升级Python导致yum不能用,提示No module named yum,说是找不到yum模块,在某些情况下修改/usr/bin/yum环境指向可以解决问题,但不推荐此方法,建议卸载Python和yum重新rpm安装。
卸载
rpm -qa | grep yum | xargs rpm -ev --allmatches --nodeps #强制删除yum
rpm -qa | grep python | xargs rpm -ev --allmatches --nodeps #强制删除python
whereis python |xargs rm -frv #相关依赖
whereis yum|xargs rm -fr #相关依赖
安装
下载镜像包 https://mirrors.aliyun.com/centos/6/isos/x86_64/CentOS-6.10-x86_64-minimal.iso
mkdir /iso
mount -o loop -t iso9660 CentOS-6.10-x86_64-minimal.iso /iso/
cd /iso/cd Packages/
#同时安装两个包
rpm -ivh python-libs-2.6.6-66.el6_8.x86_64.rpm python-2.6.6-66.el6_8.x86_64.rpm
#安装依赖
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh python-pycurl-7.19.0-9.el6.x86_64.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
#安装yum
rpm -iUh rpm-4.8.0-59.el6.x86_64.rpm rpm-libs-4.8.0-59.el6.x86_64.rpm
rpm -iUh rpm-python-4.8.0-59.el6.x86_64.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
测试
[root@svn ~]# yum --version
3.2.29
Installed: rpm-4.8.0-59.el6.x86_64 at 2018-11-09 10:35
Built : CentOS BuildSystem <http://bugs.centos.org> at 2018-06-19 15:56
Committed: Panu Matilainen <pmatilai@redhat.com> at 2018-03-26
Installed: yum-3.2.29-81.el6.centos.0.1.noarch at 2018-11-09 10:38
Built : CentOS BuildSystem <http://bugs.centos.org> at 2018-10-10 14:09
Committed: Johnny Hughes <johnny@centos.org> at 2018-10-10
Installed: yum-plugin-fastestmirror-1.1.30-42.el6_10.noarch at 2018-11-09 10:38
Built : CentOS BuildSystem <http://bugs.centos.org> at 2018-07-30 15:30
Committed: Michal Domonkos <mdomonko@redhat.com> at 2018-07-24
[root@svn ~]#
[root@svn ~]#
[root@svn ~]# python -V
Python 2.6.6