---自用阿里云服务器,想着弄个Django项目上去,在昨天升级python3.7后,手贱把自带的python 2.7卸载了,导致yum不能使用,尝试了多种方法,没有修复yum,问题还在自带的python上.于是把自带的python修复后,yum可以成功使用了.
1.首先卸载python
# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
# whereis python|xargs rm -fr
2.卸载yum
# rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
# rm -rf /etc/yum.repos.d/*
# whereis yum|xargs rm -fr
3.重新安装python2.7
创建文件夹:mkdir /usr/local/src/python
进入目录:cd /usr/local/src/python
--wget 没有指定路径的话,就默认在当前路径下载,同时要注意自己的版本是Centos7.几
下载包
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
安装
# rpm -ivh python-* rpm-python-*
如果出现安装包的依赖问题,此时如下解决即可:
# rpm -ivh python-* rpm-python-* --nodeps --force
--nodeps --force 为不考虑依赖包强制安装.
4.重装 yum
创建文件夹:mkdir /usr/local/src/yum
进入目录:cd /usr/local/src/yum
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
安装:
rpm -ivh yum-*
5.验证
输入yum 或者rpm -qa yum 查看有无报错
输入yum makecache 验证是否安装成功