【发布时间】:2018-08-17 07:16:30
【问题描述】:
我尝试运行的任何 yum 命令都会返回以下内容:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
cannot import name Errors
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.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
这就是我所做的和我所知道的:
操作系统是红帽 4.4.7018
我相信 Python 是 2.6,前段时间更新到 2.7(我怀疑这可能破坏了 yum)
python -V 返回 2.7.13
# ls -lrt /usr/bin/python*
-rwxr-xr-x. 1 root root 4864 Aug 18 2016 /usr/bin/python2.6
lrwxrwxrwx. 1 root root 6 Mar 8 13:16 /usr/bin/python2 -> python
lrwxrwxrwx. 1 root root 24 Mar 8 13:32 /usr/bin/python -> /usr/local/bin/python2.7
# ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.6
# ls /usr/local/bin/python*
/usr/local/bin/python2.7 /usr/local/bin/python2.7-config
我尝试在所有 phyton 上运行 import yum,只有 2.6 不会给我错误,所以我尝试将链接更改回 2.6(通过 python -V 验证以检查它是否返回到版本 2.6.6 ),yum 仍然返回“cannot import name Errors”错误。
另外,PATH 变量:
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/root/bin
/usr/bin/yum上配置的python是#!/usr/bin/python2.6,我试过改成/python,甚至/phyton2还是报错。
【问题讨论】: