How to Fix Common yum Errors on CentOS 7: 404, Failed Installs, and Missing Python
This guide walks you through diagnosing and resolving typical yum command failures on CentOS 7—including 404 repository errors, package installation failures caused by immutable file attributes, and missing Python interpreter issues—providing step‑by‑step commands, repository configuration tips, and file‑system fixes to restore yum functionality.
Introduction
This article explains how to troubleshoot common yum command failures on CentOS 7.
1. yum returns 404 error
Check that the yum repository is correctly configured, for example by downloading a repo file from Alibaba Cloud.
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoIf the error mentions the $releasever variable, verify that the centos-release package is installed: rpm -qa | grep centos-release If it is missing, install it:
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/centos-release-7-7.1908.0.el7.centos.x86_64.rpm
rpm -ivh centos-release-7-7.1908.0.el7.centos.x86_64.rpm2. yum install fails with “failed” error
Example error when installing telnet:
ERROR UNpacking rpm package 1:telnet-0.17-64.e17.x86_64
error:unpacking of archive failed on file /usr/bin/telnet;5e785bc7:cpio:openCheck the attributes of the target directory; an immutable (i) attribute can prevent writing: lsattr /usr/bin Remove the immutable flag:
chattr -i /usr/bin3. yum reports missing Python interpreter
yum is a Python script; if /usr/bin/python is missing, yum cannot run.
Inspect the yum script header: cat /usr/bin/yum Check whether the Python binary exists: ls -al /usr/bin/python If the file is absent or renamed, restore it or reinstall Python. Example steps:
List installed Python packages: rpm -qa | grep python Check existing Python binaries: ls -al /usr/bin/python* If Python was removed, download the packages on another similar system and copy them to the affected host:
mkdir /python/
yum install python --downloadonly --downloaddir=/python/
scp /python/* root@<em>host</em>:/tmp/
cd /tmp
rpm -ivh *Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
