centos 卸载python和yum之后的解决办法
admin2024-08-14 10:13:38Linux运维
由于之前的失误卸载了python2.6,导致没法使用yum。哪怕重新装会python2.6也没用。
出现的问题 no module named yum。
①卸载python与yum
rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
whereis python|xargs rm -fr
rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
rm -rf /etc/yum.repos.d/*
whereis yum|xargs rm -fr
②安装python
推荐使用这个:http://vault.centos.org/6.8/os/x86_64/Packages/ 。其中6.8为centos的版本号,x86_64为64位系统
mkdir /usr/local/src/python
cd /usr/local/src/python
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-2.6.6-64.el6.x86_64.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-devel-2.6.6-64.el6.x86_64.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-libs-2.6.6-64.el6.x86_64.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/rpm-python-4.8.0-55.el6.x86_64.rpm
rpm -ivh python-* rpm-python-*
这有可能有已经安装的包有了依赖关系,只需要卸载了重装就好
③安装yum
mkdir /usr/local/src/yum
cd /usr/local/src/yum
wget http://vault.centos.org/6.8/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://vault.centos.org/6.8/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
rpm -ivh yum-*
④测试
yum
显示出命令列表就可以了