最近在项目中使用yum安装其他软件,手贱无意间把python卸载,导致无法使用yum,尝试着安装python,按照网上教程配置#!/usr/bin/yum第一行#/usr/bin/python改为#!/usr/bin/python2.7或者改为#!/usr/bin/python3.6,然后并没有什么用。
继续参考网上教程全部卸载yum重新安装,类似下边安装流程,误导性太大, 并没有什么用处,随采用rpm方式安装
查询linux版本信息
cat /etc/redhat-release
在Index of /centos/7/os/x86_64/Packages/页面查询对应的rpm文件信息
安装完成,尝试使用yum安装rz\sz命令
yum install -y lrzsz 报了下边错误
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
/usr/lib64/python2.7/site-packages/rpm/_rpm.so: undefined symbol: rpmpkgVerifySigs
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, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
centos出现了rpmpkgverifySigs问题,rpmpkgverifySigs 为对/usr/lib64/python2.7/site-packages/rpm/_rpm.so的调用
通过查询发现是python版本发现rpm-python-4.11.3.25.el7.x86_64导致
执行rpm -qa|grep python
python-devel-2.7.5-58.el7.x86_64
python-urlgrabber-3.10-8.el7.noarch
python-2.7.5-58.el7.x86_64
python-pycurl-7.19.0-19.el7.x86_64
python-libs-2.7.5-58.el7.x86_64
python-iniparse-0.4-9.el7.noarch
rpm-python-4.11.3-25.el7.x86_64
通过rpm -Uvh * --nodeps安装http://mirrors.163.com/centos/7/os/x86_64/Packages/下载的
python-2.7.5-88.el7.x86_64.rpm python-pycurl-7.19.0-19.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-devel-2.7.5-88.el7.x86_64.rpm python-urlgrabber-3.10-10.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
python-iniparse-0.4-9.el7.noarch.rpm rpm-python-4.11.3-43.el7.x86_64.rpm
python-libs-2.7.5-88.el7.x86_64.rpm yum-3.4.3-167.el7.centos.noarch.rpm
由于http://mirrors.163.com/centos/7/os/x86_64/Packages/目录一直处于更新状态,可能会出现版本号更新导致查不到相关rpm,只需要使用查询到的版本即可
卸载python和yum配置信息
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
whereis python | xargs rm -frv
rpm -qa|grep yum | xargs rpm -ev --allmatches --nodeps
whereis yum | xargs rm -frv
下载rpm包,如下所示:
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-43.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-sign-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/dbus-python-devel-1.1.1-9.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-virtualenv-15.1.0-4.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm
执行以下命令一键安装完成即可使用yum
rpm -Uvh --force --nodeps --replacepkgs *.rpm