(升级或卸载Python导致 yum出错)
一: 升级python导致yum出错
1. cd /usr/bin/yum
2. #!/usr/bin/python 修改为 #!/usr/bin/python2.6
二 :完全重装python和yum(卸载系统的安装的python)
<1> 删除python包
1. whereis python # 查看当前系统安装的python包
2. rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除系统安装程序python包及其相关
3. whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
4. whereis python ##验证删除,返回无结果
<2> 删除现有yum
1.rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
2. whereis yum |xargs rm -frv
<3>下载相应的rpm包 (centos6版本) http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/
注意:rpm包的版本会更新,查看上面链接的源 具体下载
1.下载相应的rpm包
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
wgt http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-setuptools-0.6.10-4.el6_9.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-utils-1.1.30-41.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
2. rpm相应包
rpm -Uvh --replacepkgs python*.rpm
rpm -Uvh --force --nodeps --replacepkgs rpm-python*.rpm yum*.rpm (--force --nodeps 强制安装 解决依赖问题)
文章来源于:
http://blog.51cto.com/smilepad/1333478(安装python2.6 和yum)
https://segmentfault.com/q/1010000009194060/a-1020000010325662 (rpm 安装依赖问题):
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm