Centos6.5,误删了Python2.6以及Yum,怎么处理?

一、删除所有Python

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

二、删除现有的YUM

[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[root@test ~]# whereis yum |xargs rm -frv

三、下载需要的包:http://mirrors.aliyun.com/cen...

python-2.6.6-66.el6_8.x86_64.rpm
python-iniparse-0.3.1-2.1.el6.noarch.rpm
python-libs-2.6.6-66.el6_8.x86_64.rpm
python-pycurl-7.19.0-9.el6.x86_64.rpm
python-urlgrabber-3.9.1-11.el6.noarch.rpm
python-setuptools-0.6.10-3.el6.noarch.rpm
python-devel-2.6.6-36.el6.x86_64.rpm

rpm-4.8.0-59.el6.x86_64.rpm
rpm-libs-4.8.0-59.el6.x86_64.rpm
rpm-python-4.8.0-59.el6.x86_64.rpm

yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm
yum-utils-1.1.30-41.el6.noarch.rpm
zlib-1.2.3-29.el6.x86_64.rpm
zlib-devel-1.2.3-29.el6.x86_64.rpm

libxml2-2.7.6-21.el6_8.1.x86_64.rpm
libxml2-devel-2.7.6-21.el6_8.1.x86_64.rpm
libxml2-python-2.7.6-21.el6_8.1.x86_64.rpm

四、安装

由于安装过程中,多个包存在相互依赖的关系,所有这里一起安装。

[root@test ~]# rpm -Uvh --replacepkgs python*.rpm
[root@test ~]# rpm -Uvh --replacepkgs rpm-*.rpm yum*.rpm zlib-*.rpm libxml2-*.rpm

五、测试

[root@test ~]# python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>> 

到此,就结束了。

你可能感兴趣的:(python,yum,centos6.5)