No module named yum错误的解决办法

今天使用yum安装程序,报错 原来是我之前调试东西的时候,安装了其他版本的python导致的。

网上搜了一下问题处理,解决了,记录一下。

[jumpserver@SX-Test-Nginx ~]$ sudo yum install -y epel-release
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.6 (default, Jul  8 2018, 14:42:57) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

检查一下python环境

[jumpserver@SX-Test-Nginx ~]$ whereis python
python: /usr/bin/python2.6 /usr/bin/python.bak /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/local/python2.7 /usr/share/man/man1/python.1.gz
[jumpserver@SX-Test-Nginx ~]$ python
Python 2.7.6 (default, Jul  8 2018, 14:42:57) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>> exit()
[jumpserver@SX-Test-Nginx ~]$ ls -l /usr/bin/yum 
-rwxr-xr-x. 1 root root 801 Mar 22  2017 /usr/bin/yum
[jumpserver@SX-Test-Nginx ~]$ ls /usr/bin/ |grep python
python
python2
python2.6
python.bak

直接修改yum,将python修改成python2.6

[jumpserver@SX-Test-Nginx ~]$ sudo vim /usr/bin/yum
#!/usr/bin/python2.6

修改完后再yum安装就可以了。

[jumpserver@SX-Test-Nginx ~]$ sudo yum install -y epel-release
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
base                                                                                                                                  | 3.7 kB     00:00     
epel                                                                                                                                  | 3.2 kB     00:00     
epel/primary                                                                                                                          | 3.2 MB     00:00     
epel                                                                                                                                             12516/12516
extras                                                                                                                                | 3.4 kB     00:00     
updates                                                                                                                               | 3.4 kB     00:00     
updates/primary_db                                                                                                                    | 667 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                    Arch                                 Version                            Repository                          Size
=============================================================================================================================================================
Installing:
 epel-release                               noarch                               6-8                                epel                                14 k

Transaction Summary
=============================================================================================================================================================
Install       1 Package(s)

Total download size: 14 k
Installed size: 22 k
Downloading Packages:
epel-release-6-8.noarch.rpm                                                                                                           |  14 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : epel-release-6-8.noarch                                                                                                                   1/1 
warning: /etc/yum.repos.d/epel.repo created as /etc/yum.repos.d/epel.repo.rpmnew
  Verifying  : epel-release-6-8.noarch                                                                                                                   1/1 

Installed:
  epel-release.noarch 0:6-8                                                                                                                                  

Complete!

 

posted on 2018-07-31 16:15  LiuDan182  阅读(702)  评论(0)    收藏  举报

导航