centos7.4出现yum command not found

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

通过将云主机自带的yum和python卸载掉,并且同时需要关注/usr/bin/yum文件的首行解释。我定义其为"#!/usr/bin/python"

1.卸载python:

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

2.卸载yum:

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

3.创建目录python和yum用以存放rpm包:

1 mkdir /usr/local/src/python
2 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.rpm
5 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm
6 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-devel-2.7.5-34.el7.x86_64.rpm
7 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-libs-2.7.5-34.el7.x86_64.rpm
8 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-urlgrabber-3.10-7.el7.noarch.rpm
9 #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.rpm
5 #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-* 

 

posted @ 2019-04-23 22:36  小王同学-TT  阅读(23776)  评论(3编辑  收藏  举报