无法 yum 安装任何软件包

无法 yum 安装任何软件包

无论我尝试安装什么包,Yum 都会[Errno 5] [Errno 2] No such file or directory error为每个包/依赖项返回一个。

这是一些示例输出:

# yum -y install vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ocf.berkeley.edu
 * extras: mirror.tocici.com
 * updates: mirror.sesp.northwestern.edu
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.160-1.el7_3.1 will be installed
--> Processing Dependency: vim-common = 2:7.4.160-1.el7_3.1 for package: 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.7-5.el7 will be installed
---> Package vim-common.x86_64 2:7.4.160-1.el7_3.1 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.160-1.el7_3.1.x86_64
--> Running transaction check
---> Package vim-filesystem.x86_64 2:7.4.160-1.el7_3.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================
 Package                                                     Arch                                                Version                                                           Repository                                            Size
==============================================================================================================================================================================================================================================
Installing:
 vim-enhanced                                                x86_64                                              2:7.4.160-1.el7_3.1                                               updates                                              1.0 M
Installing for dependencies:
 gpm-libs                                                    x86_64                                              1.20.7-5.el7                                                      base                                                  32 k
 vim-common                                                  x86_64                                              2:7.4.160-1.el7_3.1                                               updates                                              5.9 M
 vim-filesystem                                              x86_64                                              2:7.4.160-1.el7_3.1                                               updates                                              9.7 k

Transaction Summary
==============================================================================================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 7.0 M
Installed size: 23 M
Downloading packages:


Error downloading packages:
  gpm-libs-1.20.7-5.el7.x86_64: [Errno 5] [Errno 2] No such file or directory
  2:vim-filesystem-7.4.160-1.el7_3.1.x86_64: [Errno 5] [Errno 2] No such file or directory
  2:vim-enhanced-7.4.160-1.el7_3.1.x86_64: [Errno 5] [Errno 2] No such file or directory
  2:vim-common-7.4.160-1.el7_3.1.x86_64: [Errno 5] [Errno 2] No such file or directory

看起来它能够连接到存储库并看到所需的包/依赖项,但是当它下载时却失败了。我对管理 repos 和 yum 不太了解,但这看起来可能是本地计算机上的问题?

Distro 是 AWS 上的 CentOS Linux 版本 7.2.1511(核心)。

答案1

在其中一台服务器上,我注意到该文件的/usr/libexec/urlgrabber-ext-down顶部有以下内容: #! /usr/bin/python
但是 python 符号链接已损坏。输入python --version会抛出错误,说command not found
Created a symlink for python pointing to python2.7 并且解决了问题

答案2

你应该没问题

ln -s /usr/libexec/urlgrabber-ext-down-2.7 /usr/libexec/urlgrabber-ext-down

答案3

如果你阅读 yum 和 urlgrabber 的源代码你会发现:

yum 使用 python 模块urlgrabber下载 rpm 包,其高级异步 apiparallel_wait与包的内部类相关联_ExternalDownloader

urlgrabber-ext-down的目录是硬代码在课堂上_ExternalDownloader写成/usr/libexec/urlgrabber-ext-down2075号线urlgrabber/grabber.py

def __init__(self):
    self.popen = subprocess.Popen(
        '/usr/libexec/urlgrabber-ext-down',
        stdin = subprocess.PIPE,
        stdout = subprocess.PIPE,
    )
    self.stdin  = self.popen.stdin.fileno()
    self.stdout = self.popen.stdout.fileno()
    self.running = {}
    self.cnt = 0

所以只要确保你的urlgrabber-ext-down就在那里,或者重写代码2075号线

答案4

这为我解决了这个问题https://blog.51cto.com/chaichuan/2083574。基本上必须将链接中提到的两个文件中的python版本更改为2.7

相关内容