解决centos6上python升级混乱导致yum报错 -bash: /usr/bin/yum: /usr/bin/python

亲测方法二解决问题

由于服务器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
[GCC 4.4.6 (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。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值