前言
腾讯云服务器上的本机python环境被我不小心卸载了,而yum依赖python环境,当我重新安装同版本的python环境后,做了如下操作,没有解决yum不能使用的问题(no module named yum):
whereis yum whereis python sudo rm -rf /usr/bin/python sudo ln -s /usr/bin/python2.6/bin/python /usr/bin/python
整个重新安装过程
1、删除现有的python
rpm -qa|grep python|xargs rpm -ev –allmatches –nodeps ##强制清除已安装的程序及其关联
whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果说明清除干净
2、删除现有的yum
rpm -qa|grep yum|xargs rpm -ev –allmatches –nodeps
whereis yum |xargs rm -frv
3、检查CentOS 7版本
cat /etc/centos-release
4、找到对应的依赖下载
http://vault.centos.org/
http://mirrors.163.com/
- python-2.7.5-34.el7.x86_64.rpm
- python-iniparse-0.4-9.el7.noarch.rpm
- python-libs-2.7.5-34.el7.x86_64.rpm
- python-pycurl-7.19.0-17.el7.x86_64.rpm
- python-urlgrabber-3.10-7.el7.noarch.rpm
- rpm-python-4.11.3-17.el7.x86_64.rpm
- yum-3.4.3-132.el7.centos.0.1.noarch.rpm
- yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/python-2.7.5-34.el7.x86_64.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/python-urlgrabber-3.10-7.el7.noarch.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/rpm-python-4.11.3-17.el7.x86_64.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/python-libs-2.7.5-34.el7.x86_64.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
5、安装
rpm -Uvh --replacepkgs python*.rpm
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force
6、验证