首页 > 代码库 > No module named yum解决办法
No module named yum解决办法
(1)错误提示:
[root@gflinux4 ~]# 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 的位置:
[root@gflinux4 ~]# 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
>>>
[root@gflinux4 ~]# 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的安装路径
[root@gflinux4 ~]# cd /usr/local/python/bin/
[root@gflinux4 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文件的头信息如下:
[root@gflinux4 bin]# vi /usr/bin/yum
#!/usr/bin/python => #!/usr/bin/python2
import sys
try:
再次运行如下:
[root@gflinux4 ~]# yum
/usr/bin/python: can‘t open file ‘=> #!/usr/bin/python2‘: [Errno 2] No such file or directory
OK测试成功。
No module named yum解决办法