您的当前位置:首页正文

centos7.4出现yumcommandnotfound

2020-02-10 来源:步旅网
centos7.4出现yumcommandnotfound

购买的云服务器运⾏yum命令出现yum command not found。

通过将云主机⾃带的yum和python卸载掉,并且同时需要关注/usr/bin/yum⽂件的⾸⾏解释。我定义其为\"#!/usr/bin/python\"1.卸载python:

1 rpm -qa|grep python|xargs rpm -e --allmatches --nodeps2 whereis python|xargs rm -fr

2.卸载yum:

1 rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps2 rm -rf /etc/yum.repos.d/*3 whereis yum|xargs rm -fr

3.创建⽬录python和yum⽤以存放rpm包:

1 mkdir /usr/local/src/python2 mkdir /usr/local/src/yum

4.使⽤wget分别下载python以及yum的rpm包(注意:⼀定要和系统的版本号对应) (1)下载python的rpm包:

1 #cd /usr/local/src/python 进⼊⽬录2

3 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-2.7.5-34.el7.x86_64.rpm

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

(2)下载yum的rpm包:

1 #cd /usr/local/src/yum 2

3 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm

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

5.安装python以及yum的rpm包(1)安装python:

1 #cd /usr/local/src/python 2

3 #rpm -ivh python-* rpm-python-*

4 出现安装包的依赖问题,此时如下解决即可:5

6 #rpm -ivh python-* rpm-python-* --nodeps --force

7 --nodeps --force为不考虑依赖包,强制安装。8

9 安装完后即可运⾏python:

(2)安装yum:

1 #cd /usr/local/src/yum 2 #rpm -ivh yum-*

因篇幅问题不能全部显示,请点此查看更多更全内容