刪除了自帶python,使用yum報錯bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

想安裝Python3,因爲Centos 自帶Python2,想要果斷卸載掉,導致yum無法使用。

前期準備:

卸載python:

rpm -qa|grep python|xargs rpm -e --allmatches --nodeps

whereis python|xargs rm -fr

卸載yum:

rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps

rm -rf /etc/yum.repos.d/*

whereis yum|xargs rm -fr

1).找到原來的安裝iso文件,將其中的python和yum相關文件都提取出來放到linux中(備用:去http://rpm.pbone.net/ 這個地方搜索對應的rpm安裝包下載)

   

2) 通過“search”搜索以下RPM包(主要是Python 2.7.5 以及依賴項):

python-libs-2.7.5-76.el7.x86_64.rpm

python-2.7.5-76.el7.x86_64.rpm

python-devel-2.7.5-76.el7.x86_64.rpm

python-iniparse-0.4-9.el7.noarch.rpm

python-pycurl-7.19.0-19.el7.x86_64.rpm

python-urlgrabber-3.10-9.el7.noarch.rpm

rpm-python-4.11.3-35.el7.x86_64.rpm

yum-metadata-parser-1.1.4-10.el7.rpm

yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

yum-3.4.3-161.el7.centos.noarch.rpm


3) 接下來rpm -ivh  rpm包名稱進行安裝 (注意:rpm包安裝順序, 如果發現“已經安裝,包依賴衝突”):

       1、包依賴衝突解決:rpm -e 包名稱 --nodeps

       2、安裝順序一定要按照上面的順序來一個個安裝(最後兩個一定要一起安裝,如下

 rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

使用yum命令出現如下表示說明安裝完成!

[root@2019UP yum]# yum
Loaded plugins: fastestmirror
You need to give some command
Usage: yum [options] COMMAND

終於解毒 ^(* ̄(oo) ̄)^

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章