yum という名前のモジュールはありません。python 2.7.16 を使用してください。

yum という名前のモジュールはありません。python 2.7.16 を使用してください。

CentOS yum アップデートが実行されていません。次のテキストの yum エラー メッセージを確認してください。


yum
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.16 (default, Oct 15 2019, 11:56:22)
[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

Python と pip を最新バージョンに更新します。現在のバージョンは次のとおりです:

  • Python 2.7.16 pip 19.3.1から
  • /usr/local/lib/python2.7/site-packages/pip (python 2.7)

ディレクトリからこのファイルを見る/usr/bin/yum

#!/usr/local/bin/python2.7
import sys
try:
    import yum
except ImportError:
    print >> sys.stderr, """\
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   %s

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:
%s

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

""" % (sys.exc_value, sys.version)
    sys.exit(1)

sys.path.insert(0, '/usr/share/yum-cli')
try:
    import yummain
    yummain.user_main(sys.argv[1:], exit_code=True)
except KeyboardInterrupt, e:
    print >> sys.stderr, "\n\nExiting on user cancel."
    sys.exit(1)

そして、pip3とpython3をインストールしてテストしました

Pip error during yum installation

pip install yum 

ERROR: Could not find a version that satisfies the requirement yum (from versions: none)
ERROR: No matching distribution found for yum

答え1

scp を使用して、他のサーバーから焦点となる Python パッケージに Python をコピーできます。->> ライブラリのコピーが完了したら、次のyumコマンドを私のサーバーで実行します。

scp -r [email protected]:/usr/lib/python2.7/site-packages /usr/lib/python2.7/

関連情報