概述
最近安装python3.x版本将Centos6.10中自带的低版本python通过yum卸载后,导致yum功能无法正常使用,后来才知道yum的功能是通过python编写,需要依赖python的低版本,高版本的python与yum功能无法兼容,此时就需要安装Centos系统自带的python版本。无法使用的yum如下图所示:
1.环境重现
卸载yum
rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
rm -rf /etc/yum.repos.d/*
whereis yum|xargs rm -rf
卸载python
rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
whereis python|xargs rm -rf
3.系统查看
查看系统版本
cat /etc/centos-release
查看位数
uname -a
4.安装python
在镜像站中找到系统版本和位数所对应的python rpm包,在这里采用的是阿里云的镜像(https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/),系统版本:centos 6.10 64位
创建python目录,存放rpm包
mkdir /usr/local/src/python
切换到python目录下
cd /usr/local/src/python
下载python相关rpm包
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm
rpm安装python
rpm -ivh python-* rpm-python-*
5.安装yum
与安装python一样需要找到对应系统版本的rpm包下载到本地,通过rpm安装]
创建yum目录,存放rpm包
mkdir /usr/local/src/yum
切换到yum目录
cd /usr/local/src/yum/
下载rpm包
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6.10/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
rpm安装yum
rpm -ivh yum-*
6.测试安装结果
yum
python -V
由于前面将yum.repos.d文件删除了,需要重新安装yum仓库源,不然yum找不到yum源导致功能无法正常使用,可参照我博文中:https://blog.csdn.net/cen50958/article/details/88964298 中10.设置yum源,将yum源设置为阿里云。
最后
以上就是高兴项链为你收集整理的Centos6.10 yum和python被卸载后重新安装的全部内容,希望文章能够帮你解决Centos6.10 yum和python被卸载后重新安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复