Loading

CentOS误删python环境后怎么办?

Linux自带python2相关依赖,由于安装python3,怕会产生版本冲突,索性头脑一热,就把python2相关依赖包给删掉了,最后执行yum命令就出现下面这个错误

yum命令在linux还是经常有使用的,现在突然不能够使用,得想办法解决才行,经过百度相关经验贴,总结出以下解决办法。

目录

1、查看Linux系统版本

2、下载相关依赖

2.1、下载依赖

2.2、安装依赖

3、效果展示


1、查看Linux系统版本

 cat /etc/redhat-release

通过命令,我们得知我使用的Linux版本是 :7.5.1804

2、下载相关依赖

首先新建一个目录,放我们接下来需要下载的yum和python相关依赖包

#创建目录并进入
mkdir python_and_yum && cd $_

2.1、下载依赖

wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/lvm2-python-libs-2.02.177-4.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-libs-2.7.5-68.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-2.7.5-68.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/rpm-python-4.11.3-32.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
wget http://vault.centos.org/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

2.2、安装依赖

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

3、效果展示

如果一切安装顺利,就可以使用以下两个命令进行查询相关版本

posted @ 2023-02-01 17:46  Roc-xb  阅读(53)  评论(0编辑  收藏  举报

易微帮源码


易微帮官网