No module named yum解决办法

(1)错误提示:

[[email protected] ~]# yum -y install kernel-debuginfo-common-2.6.18-238.el5

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.8 (default, Oct 31 2014, 09:32:25)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]

If you cannot solve this problem yourself, please go to

the yum faq at:

http://wiki.linux.duke.edu/YumFaq

(2)解决办法

yum是python的一个模块,在安装python时会自动安装后。

python 的位置:

[[email protected] ~]# python

Python 2.7.8 (default, Oct 31 2014, 09:32:25)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> exit

Use exit() or Ctrl-D (i.e. EOF) to exit

>>>

[[email protected] ~]# whereis python

python: /usr/bin/python /usr/lib/python2.4 /usr/include/python2.4 /usr/local/python /usr/share/man/man1/python.1.gz

查看python的安装路径

[[email protected] ~]# cd /usr/local/python/bin/

[[email protected] bin]# ll

total 4488

-rwxr-xr-x 1 root root     108 Oct 31 09:33 2to3

-rwxr-xr-x 1 root root     314 Nov  3 10:26 easy_install

-rwxr-xr-x 1 root root     322 Nov  3 10:26 easy_install-2.7

-rwxr-xr-x 1 root root     106 Oct 31 09:33 idle

-rwxr-xr-x 1 root root      91 Oct 31 09:33 pydoc

lrwxrwxrwx 1 root root       7 Oct 31 09:34 python -> python2

lrwxrwxrwx 1 root root       9 Oct 31 09:34 python2 -> python2.7

-rwxr-xr-x 1 root root 4535058 Oct 31 09:33 python2.7

-rwxr-xr-x 1 root root    1681 Oct 31 09:34 python2.7-config

lrwxrwxrwx 1 root root      16 Oct 31 09:34 python2-config -> python2.7-config

lrwxrwxrwx 1 root root      14 Oct 31 09:34 python-config -> python2-config

-rwxr-xr-x 1 root root   18554 Oct 31 09:33 smtpd.py

修改/usr/bin/yum文件的头信息如下:

[[email protected] bin]# vi /usr/bin/yum

#!/usr/bin/python => #!/usr/bin/python2

import sys

try:

再次运行如下:

[[email protected] ~]# yum

/usr/bin/python: can‘t open file ‘=> #!/usr/bin/python2‘: [Errno 2] No such file or directory

OK测试成功。

时间: 2024-10-25 02:27:34

No module named yum解决办法的相关文章

Linux下yum出现no module named pycurl 解决办法

1.1 no module named pycurl 解决办法 下载curl:http://curl.haxx.se/download/curl-7.21.3.tar.gz tar xzf curl-7.21.3.tar.gz ./configure make make install 下载pycurl:http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz tar xzf pycurl-7.19.0.tar.gz cd pycur

命令行运行python项目文件,报错:ModuleNotFoundError: No module named 'xxxx' 解决办法

在pycharm中写好了自动化测试脚本,并能在pycharm中正常运行,由于要考虑到无人值守时能自动执行,执行时就需要脱离pycharm,直接能用命令执行.但是直接用命令执行用例文件:python3 D:\pycode\autotest_framework\case\run_case.py 结果报错,找不到模块 自动化项目的结构如下:用例run_case.py 和工具类utils下的工具 不在同一个文件夹下面.在脚本中需要导入包如: from utils.HTMLTestRunner impor

python---No module named 'requests'解决办法

requests介绍 requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那我们为什么要用requests而不用urllib2呢?官方文档中是这样说明的:python的标准库urllib2提供了大部分需要的HTTP功能,但是API太逆天了,一个简单的功能就需要一大堆代码.所以requests是比较简单方便的库. 遇到问题 我们在一个需要使用requests的脚本里引用了requests import requests1运行时报错No module named

Centos 7 python 编译报错 ImportError: No module named six 解决办法

本地编译Open vSwitch时报错 Traceback (most recent call last):   File "./ovsdb/ovsdb-idlc.in", line 8, in <module>     import ovs.json   File "/root/rpmbuild/BUILD/openvswitch-2.6.0/python/ovs/json.py", line 21, in <module>     imp

py2exe生成exe后,运行exe时提示No module named * 的解决办法

根据 http://www.tuicool.com/articles/7RbU3i ,应该是没有显式地import相关module. 运行exe的时候提示缺什么模块就import什么模块,并在代码里面显示的调用一次 http://www.pceworld.com/view/6937505 1.In the program you are trying to import (eg. in the A.py for A.exe ), specify import statement for _mss

CentOS6.5 安装Python2.7后, yum出现“No module named yum”错误

安装如下方法安装python2.7: yum install –y python27 python27-devel Python-docutils cd /usr/bin/ rm -rf python cp python2.7 python   出现yum错误:No module named yum 解决方法,查看 /usr/bin下python有哪几个版本 ll /usr/bin 我这里是:2.6  和  2.7 (刚安装的) 由于yum命令不兼容python2.7,需修改/usr/bin/y

No module named 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 c

python升级导致yum不可用 “ No module named yum”

最近在看python,虚拟机装的是Centos6.6,自带的python版本是2.6.6,打算升级到2.7. 我的升级过程大致如下: 下载2.7源码包https://www.python.org/downloads/source/ 卸载旧的python,rpm -e python 编译安装python2.7 整个过程没有遇到问题,但升级完后,再用yum安装软件时报如下错误 [[email protected] python]# yum There was a problem importing 

import yum\r\nImportError: No module named yum

报错:FAILED! => {"changed": false, "module_stderr": "Shared connection to 192.168.10.10 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_NDuf1p/ansible_module_yum