【转载】centos重新安装,卸载python yum

【转载】centos重新安装,卸载python yum

原标题centos重新安装,卸载python yum

本文标题:记一次完全卸载centos自带python填坑!!!

博主想装一个新版本的python,暴躁的删除了centos自带的python。从而引发yum不能使用的情况!!身为强迫症的我,不能忍受!必须修复。经过我个人重装了原来版本的python(这里使用了源码安装,编译、make、make install),修改 /usr/bin/yum里面的代码,最终还是导致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.6.1 (r261:67515, Aug 7 2010, 11:36:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]


If you cannot solve this problem yourself, please go to
the yum faq at:
http://wiki.linux.duke.edu/YumFaq

找遍了解决办法,终于在下面的方法中找到了最终的方法
原文链接:https://www.centos.bz/2017/11/centos%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85%EF%BC%8C%E5%8D%B8%E8%BD%BDpython-yum/

完全卸载python

这里的命令慎重执行!!!
这里的命令慎重执行!!!
这里的命令慎重执行!!!

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

删除现有的yum

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

下载对应的rpm包

镜像地址:http://mirrors.163.com/centos
解压使用的iso镜像(推荐):(\CentOS-XX-x86_64-bin-DVD1\Packages)

python-2.6.6-36.el6.x86_64.rpm
python-devel-2.6.6-36.el6.x86_64.rpm
python-libs-2.6.6-36.el6.x86_64.rpm
python-pycurl-7.19.0-8.el6.x86_64.rpm
python-setuptools-0.6.10-3.el6.noarch.rpm
python-urlgrabber-3.9.1-8.el6.noarch.rpm  
python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm-python-4.8.0-32.el6.x86_64.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-utils-1.1.30-14.el6.noarch.rpm
yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm     
yum-plugin-protectbase-1.1.30-14.el6.noarch.rpm
yum-plugin-aliases-1.1.30-14.el6.noarch.rpm
yum-plugin-downloadonly-1.1.30-14.el6.noarch.rpm

安装rpm包

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

可能之间还需要zlib和zlib-devel包,根据情况下载并安装!

安装过程中遇到的问题

error: Failed dependencies:
	libxml2-python is needed by yum-utils-1.1.30-37.el6.noarch

error: Failed dependencies:
	rpm = 4.8.0-55.el6 is needed by rpm-python-4.8.0-55.el6.x86_64
	libxml2-python is needed by yum-utils-1.1.30-37.el6.noarch

上述安装中遇到的问题,可以通过强制安装的方式进行安装:
这里参考了:https://segmentfault.com/q/1010000009194060

rpm -i --force --nodeps  rpm-python*.rpm yum*.rpm

测试

直接输入yum命令
或者通过python控制台import yum 不报错即为代表成功

yum

[root@node132 iso-yum-rpm]# python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>> 


安装pip

 yum -y install epel-release

 yum install python-pip

 pip install --upgrade pip

感谢各位的分享。不胜感激。

你可能感兴趣的:(ELK)