centos 上yum命令删除补救方法

由于服务器centos6.8安装tensorflow,安装python版本过多导致链接混乱,最终yum无法使用

yum后出现

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


   No module named yum


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.9 (default, Mar 27 2015, 18:24:01) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]


If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq


服务器没有yum几乎就是残废的系统,无论如何yum都要补上

方法一:# python --version查看python 版本
# whereis python 查看python文件
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.7 /usr/lib/python2.6 /usr/lib64/python2.7 /usr/lib64/python2.6 /usr/include/python2.7 /usr/share/man/man1/python.1.gz
centos6.8基本底层python是python2.6 centos7是2.7,我的是centos6.8
解决办法
修改yum文件
#vi /usr/bin/yum
将 #!/usr/bin/python 修改为  #!/usr/bin/python2.6


以上方法解决问题后,由于手贱又安装了python2.7.5,python3.4.5 还相信网上所说改了bash/profile,最后出现
-bash: /usr/bin/yum: /usr/bin/python2.6: bad interpreter: No such file
很明显链接混乱找不到python2.6连接了
又按照不靠谱的重装yum方法,yum彻底崩了

最后找到补救方法,只有两行代码

方法二:$ rpm -qa | grep python- | grep 2.6
$  sudo rpm -ivh --force --nodeps ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/python-2.6.6-52.el6.x86_64.rpm


解决问题,yum可以使用,原理估计是python回滚到默认的2.6




方法三 非常麻烦不建议使用


  http://mirrors.163.com/centos/6/os/x86_64/Packages/
       到上面这个网站去下载如下RPM包
       python-iniparse-0.3.1-2.1.el6.noarch.rpm
       yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm 
       yum-3.2.29-69.el6.centos.noarch.rpm
       yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
       下载完成之后,用rpm命令进行安装,如下:
        rpm -ivh --force --nodeps python-iniparse-0.3.1-2.1.el6.noarch.rpm
        rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm 
        rpm -ivh --force --nodeps  yum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fa
        stestmirror-1.1.30-30.el6.noarch.rpm
到 http://yum.baseurl.org/wiki
       下载yum-3.4.3.tar.gz ,放到你指定的目录下解压,解压命令如下:
        tar -zxvf yum-3.4.3.tar.gz     #解压后进到yum-3.4.3目录
#./yummain.py update

完成之后,输入yum 解决问题


参考

http://blog.sina.com.cn/s/blog_4cbf97060100u2zb.html

http://blog.csdn.net/u011531010/article/details/53528054

http://blog.sina.com.cn/s/blog_643754960102w82m.html

http://stackoverflow.com/questions/17490921/no-module-named-rpm-when-i-call-yum-on-shell

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值