linux uninstall all python yum reinstall

Python upgrade makes yum unavailable "No module named yum"

[root@localhost python]# 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.13 (r266:84292, Jan 22 2014, 09:37:14)  
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] 
  
If you cannot solve this problem yourself, please go to  
the yum faq at: 
  http://yum.baseurl.org/wiki/Faq

Solution: uninstall and reinstall all python and yum

Step 1: Uninstall python

rpm -qa | grep python | xargs rpm -e --allmatches --nodeps

whereis python|xargs rm -fr

Step 2: Uninstall yum

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps

rm -rf /etc/yum.repos.d/*

whereis yum|xargs rm -fr

Step 3: Install python and yum

From the linux installation package ISO file, find the rpm files related to python and yum, and upload them to the linux server

mkdir /usr/local/src/python
// 上传*python*.rpm 文件到此路径下

rpm -ivh --nodeps *python* 
mkdir /usr/local/src/yum
// 上传*yum*.rpm 文件到此路径下

rpm -ivh --nodeps *yum*

Step 4: Test

[root@localhost yum]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[root@localhost yum]# yum --version
3.2.29
  Installed: rpm-4.8.0-32.el6.x86_64 at 2018-01-30 09:44
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2013-02-22 02:13
  Committed: Florian Festi <[email protected]> at 2012-11-15

  Installed: yum-3.2.29-40.el6.centos.noarch at 2018-02-02 06:27
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2013-02-22 11:26
  Committed: Johnny Hughes <[email protected]> at 2013-02-21

  Installed: yum-plugin-aliases-1.1.30-14.el6.noarch at 2018-02-02 06:27
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2012-06-22 12:23
  Committed: Zdenek Pavlas <[email protected]> at 2012-04-26

  Installed: yum-plugin-fastestmirror-1.1.30-14.el6.noarch at 2018-02-02 06:27
  Built    : CentOS BuildSystem <http://bugs.centos.org> at 2012-06-22 12:23
  Committed: Zdenek Pavlas <[email protected]> at 2012-04-26

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325146319&siteId=291194637
Recommended