yumというモジュールはありません。

yumというモジュールはありません。

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

おすすめ記事