• OS7误删yum


    报错情况:

    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:
    
      No module named sqlite
    
    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:

    1.除了误删也可能升级或卸载Python导致

    1、查看已安装python的版本,可能是当前系统存在多个python导致
    [root@test ~]# whereis python
    python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
    [root@test ~]# vi /usr/bin/yum
    将 #!/usr/bin/python 修改为 #!/usr/bin/python2.6
    如果是源代码安装的,默认路径是/usr/local/bin/python2.6,做个软链接即可
    rm -rf /usr/bin/python
    ln -s /usr/local/bin/python2.6 /usr/bin/python

    2.其他原因:完全重装python和yum

     解决:

    1)卸载python

    rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
    whereis python|xargs rm -fr

    2)卸载yum

    rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
    whereis yum|xargs rm -fr

    新建个文件夹放下载的rpm包

    mkdir /usr/local/src/python
    cd /usr/local/src/python
    #注意一下链接的包版本可能过期,最好到网站寻找新版本包
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/lvm2-python-libs-2.02.177-4.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-libs-2.7.5-68.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-2.7.5-68.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/rpm-python-4.11.3-32.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

    网站链接:http://mirrors.163.com/centos/7/os/x86_64/Packages/

    打开链接后,搜索对应包名下载到新建的文件夹中。

    3.下载完成后执行

    cd /usr/local/src/python
    rpm
    -Uvh --replacepkgs lvm2-python-libs*.rpm --nodeps --force rpm -Uvh --replacepkgs libxml2-python*.rpm --nodeps --force rpm -Uvh --replacepkgs python*.rpm --nodeps --force rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force

    安装完成后输入yum查看能否使用

  • 相关阅读:
    黑产江湖
    FW/IDS/IPS/WAF等安全设备部署方式及优缺点
    SOAPA来临,SIEM时代终结?
    美国爱因斯坦计划4
    零基础如何学好安卓开发
    协同办公系统能为企业带来怎样的影响?
    阿里腾讯开撕,钉钉的广告打到腾讯的地盘了
    bug管理工具为开发者工作带来哪些改变?
    开发人员必备的几款bug管理工具
    教你玩转产品管理系统iClap(PC端功能篇)
  • 原文地址:https://www.cnblogs.com/mergy/p/13998963.html
Copyright © 2020-2023  润新知