yum报错:bash: /usr/bin/yum: /usr/bin/python: 坏的解释器:没有那个文件或目录

把linux自带python2.7删除后yum无法应用再补救(如下)

查看系统版本

cat /etc/redhat-release

wget分别下载python yum 的rpm包

按自己的版本下载即可 找到其中的相关包 把包下载到新建的目录下

java 复制代码
# mkdir /usr/local/src/python
# cd /usr/local/src/python

文件如下(下载后总共26个文件):

java 复制代码
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-virtualenv-15.1.0-4.el7_7.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-build-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-build-libs-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-libs-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-sign-4.11.3-45.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm

安装

java 复制代码
rpm -Uvh --replacepkgs libxml2*.rpm --nodeps --force 
rpm -Uvh --replacepkgs python*.rpm --nodeps --force
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force

验证

java 复制代码
# python -V
相关推荐
闲人编程1 分钟前
Django中间件开发:从请求到响应的完整处理链
python·中间件·性能优化·django·配置·codecapsule
执笔论英雄3 分钟前
【RL】Slime异步 routout 过程7 AsyncLoopThread
开发语言·python
o***74174 分钟前
QoS质量配置
开发语言·智能路由器·php
Tony Bai4 分钟前
Go 2026 路线图曝光:SIMD、泛型方法与无 C 工具链 CGO —— 性能与表达力的双重飞跃?
开发语言·后端·golang
fj_changing5 分钟前
Ubuntu 22.04部署CosyVoice
人工智能·python·深度学习·ubuntu·ai
小二·6 分钟前
DevUI 和 MateChat:2025 年,我们是怎么把前端开发变轻松的
开发语言·javascript·vue.js
z***02606 分钟前
Python大数据可视化:基于大数据技术的共享单车数据分析与辅助管理系统_flask+hadoop+spider
大数据·python·信息可视化
i***68326 分钟前
PHP操作redis
开发语言·redis·php
kesifan6 分钟前
JAVA异常处理的基本概念
java·开发语言
雪域迷影8 分钟前
Python中通过get请求获取api.open-meteo.com网站的天气数据
开发语言·python·php