场景1: python2.7的运行环境正常
只是/usr/bin/python 软连接到了最新安装的python版本非2.7版本
直接修改/bin/yum文件,头改成/usr/bin/python2.7即可
场景2:python2.7的运行环境无法使用
如:site-packages相关包无法使用
修改卸载掉相关rpm包,然后重新安装
查看当前系统安装的yum相关rpm包
rpm -qa | grep yum
卸载几个比较主要的rpm
rpm -e --nodeps yum-plugin-fastestmirror-1.1.31-40.el7.noarch
rpm -e --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64
rpm -e --nodeps yum-3.4.3-150.el7.centos.noarch
重新安装python相关的rpm包
python-2.7.5-86.el7.x86_64.rpm
python-iniparse-0.4-9.el7.noarch.rpm
python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -ivh python-*.rpm -e --nodeps 其中 -e --nodeps 强制安装
重新安装yum相关的rpm包
yum-3.4.3-163.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
rpm -ivh yum-*.rpm
rpm包链接
http://centos.ustc.edu.cn/centos/7/os/x86_64/Packages/或http://mirrors.163.com/centos/7/os/x86_64/Packages/
如果还是出现类似如下的错误,安装相关的包即可
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named urlgrabber
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Jun 20 2019, 20:27:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
If you cannot solve this problem yourself, please go to
the yum faq at:
网友评论