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 (파이썬 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 copy python을 ->> 라이브러리 복사가 완료된 후와 같이 초점 Python 패키지로 사용할 수 있습니다. yum내 서버에서 작동하는 명령:

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

관련 정보