我尝试运行任何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
这就是我所做的和我所知道的:
操作系统是Red Hat 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
我已经尝试在所有phytons上运行import yum
,只有2.6没有给我一个错误,所以我尝试将链接更改回2.6(使用python -V
验证以检查它是否会返回到版本2.6.6),yum仍然返回“无法导入名称错误”错误。
此外,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
,我仍然会收到错误。
答案 0 :(得分:0)
旧版本的red hat(6及更早版本)中的yum命令与python 2.6一起使用
你用unlink / usr / bin / python测试yum命令,并从/ bin / python添加到/usr/bin/python2.6的新链接吗?
如果结果是相同的错误尝试重新编译python6或更新服务器上的yum pkgs
答案 1 :(得分:0)
我不是Linux专家,但这看起来像Red Hat 6(默认使用python 2.6)[1]。 4.4是GCC的版本。当你已经恢复python 2.6并且仍然需要Python 2.7时,然后通过软件集合通道安装后者 - 这将在2.6版本旁边安装2.7而不是替换它以破坏操作系统。
[1] How to confirm RedHat Enterprise Linux version? [2] https://developers.redhat.com/products/softwarecollections/hello-world/#fndtn-python