我在 centos 7 系统上运行任何 yum 命令时遇到错误
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.11 (default, Jan 29 2016, 15:44:20)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
在遇到此错误之前我做的最后一件事是 cpanm --notest XML::LibXML 不确定这是否以任何方式干扰了 python 配置。我浏览了论坛并更新了 centos 7 的 python rpm
$ ls rpm/
python-2.7.5-34.el7.x86_64.rpm
python-tools-2.7.5-34.el7.x86_64.rpm
tix-devel-8.4.3-12.el7.x86_64.rpm
yum-3.4.3-132.el7.centos.0.1.noarch.rpm.1
python-devel-2.7.5-34.el7.x86_64.rpm
tkinter-2.7.5-34.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
python-libs-2.7.5-34.el7.x86_64.rpm
tix-8.4.3-12.el7.x86_64.rpm
yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-utils-1.1.31-34.el7.noarch.rpm
$ sudo rpm -ivh *.rpm --force
这是以下命令的输出
$ python -V
Python 2.7.11
$ rpm -qi python
Name : python
Version : 2.7.5
Release : 34.el7
Architecture: x86_64
Install Date: Tue 29 Mar 2016 01:29:30 AM EDT
Group : Development/Languages
Size : 80835
License : Python
Signature : RSA/SHA256, Wed 25 Nov 2015 10:33:01 AM EST, Key ID 24c6a8a7f4a80eb5
Source RPM : python-2.7.5-34.el7.src.rpm
Build Date : Thu 19 Nov 2015 09:33:15 PM EST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.python.org/
Summary : An interpreted, interactive, object-oriented programming language
$ which python
/usr/local/bin/python
$ vim /usr/bin/yum
#!/usr/bin/python
import sys
有人可以帮我恢复 yum 命令吗?
提前致谢!
答案1
你正在使用的 python 可执行文件对我来说似乎很可疑;我手边没有一台 CentOS 机器可以检查,但我的记忆是系统提供的应该是/usr/bin/python
.
如果你跑
[$]> rpm -qf /usr/local/bin/python
它是否报告该文件归该python
包所有?
另外,输出是什么
[$]> rpm -ql python | grep bin