/usr/bin/yum /usr/bin/python: bad interpreter: No such file or directory

本文描述了一位用户在安装Python3.5.0时意外删除了yum和Python包,导致系统中/usr/bin/目录下找不到这些包并报错。用户通过查看Linux版本,卸载现有Python和yum,从CentOS官网下载依赖文件,然后在新创建的文件夹中下载并安装Python和yum的相关包来解决问题。在安装过程中遇到了依赖性问题,通过添加--nodeps--force参数强制安装解决了问题。
摘要由CSDN通过智能技术生成

今天安装python3.5.0时不小心删除删除yum以及python包导致usr/bin/目录下找不到yum以及python包报错

1、#首先查看Linux版本

[root@localhost cg]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

2、#卸载原有的python和yum

2.1、#卸载python:

$rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
$whereis python|xargs rm -fr

2.2、#卸载yum:

$rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
$rm -rf /etc/yum.repos.d/*
$whereis yum|xargs rm -fr

3、#到官网复制python和yum的相关依赖文件,一个个对着找。

https://vault.centos.org/7.2.1511/os/x86_64/Packages/

4、#新建文件夹放 python和yum文件:

$mkdir /usr/local/src/python

$mkdir /usr/local/src/yum

5、#下载python依赖包和yum依赖包

# 进入目录

$cd /usr/local/src/python

python需要的:

wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-devel-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-libs-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-urlgrabber-3.10-7.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/rpm-python-4.11.3-17.el7.x86_64.rpm

#进入目录

 $cd /usr/local/src/yum

yum需要的:

wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

6、安装python和yum:

6.1、安装python

$cd /usr/local/src/python
$rpm -ivh python-* rpm-python-*

遇到问题:

[root@localhost python]# rpm -ivh python-* rpm-python-*

error: Failed dependencies:

rpm = 4.11.3-17.el7 is needed by rpm-python-4.11.3-17.el7.x86_64

解决方法:分开安装

$rpm -ivh python-*

rpm -ivh rpm-python-* 在安装包后面加两个参数--nodeps --force其作用为不再分析包之间的依赖关系而直接安装

$rpm -ivh rpm-python-* --nodeps --force

安装成功后使用python

[root@localhost python]# python -V

Python 2.7.5

[root@localhost python]# python

Python 2.7.5 (default, Nov 20 2015, 02:00:19)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

6.2、安装yum:

$cd /usr/local/src/yum
$rpm -ivh yum-*

安装其他:

wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/curl-7.29.0-25.el7.centos.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/libcurl-7.29.0-25.el7.centos.x86_64.rpm

rpm -ivh curl* lib*

看下yum是否可使用

yum list

转载:

Linux(二十四):CentOS7.2误删除python,无法使用yum文件,需要重装 python2.7和yum!_fen_fen的博客-CSDN博客

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值