原因:
虚拟机中有python2.7和python2.6,导致yum不好用,所以删除了2.6和2.7以及yum。选择重新安装python2.6和yum。
删除:
-
删除python:
- rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps //解释:强制删除已安装程序及其关联
- whereis python |xargs rm -frv //解释:删除所有残余文件 //xargs 把管道前面whereis python执行结果当做rm -frv的参数执行。
- whereis python //验证删除结果
-
删除yum:
- rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
- whereis yum |xargs rm -frv
- whereis yum
安装:
-
安装python:
1.确认centos版本
1)、cat /etc/issue
2)、cat /etc/redhat-release
3)、cat /proc/version
4)、uname -a
2.下载rpm安装包
在http://vault.centos.org中找到对应的centos版本。以6.5为例:
1)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-2.6.6-51.el6.x86_64.rpm
2)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-devel-2.6.6-51.el6.x86_64.rpm
3)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
4)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-libs-2.6.6-51.el6.x86_64.rpm
5)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-pycurl-7.19.0-8.el6.x86_64.rpm
6)、wget http://vault.centos.org/6.5/os/x86_64/Packages/python-urlgrabber-3.9.1-9.el6.noarch.rpm
7)、wget http://vault.centos.org/6.5/os/x86_64/Packages/rpm-python-4.8.0-37.el6.x86_64.rpm
3.安装
1)、进入python包的下载目录。
2)、使用 rpm -ivh python-* rpm-python-* --nodeps --force,不考虑依赖,强制安装。
4.查看
which python
whereis python
python
-
安装yum:
1.下载rpm安装包
1)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
2)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
3)、wget http://vault.centos.org/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
2.安装
1)、rpm -ivh yum-*
3.查看
which yum
whereis yum
yum --version
写在最后:若遇到错误:Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again。
vim /etc/yum.repos.d/epel.repo ,释放第三行,屏蔽第四行,即可。
改为
每个人的做法可能不同,但是每个人都成功了,如果我们出错了,请仔细查找自己所执行的步骤。
晚安。