lib.im

Centos7重装python2.7和yum更换为阿里源
不知道哪里的问题python2.7坏了,yum也用不了了,只好重新安装了:卸载1.卸载python:#rpm -q...
扫描右侧二维码阅读全文
12
2019/10

Centos7重装python2.7和yum更换为阿里源

不知道哪里的问题python2.7坏了,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
 
#rm -rf /etc/yum.repos.d/*
 
#whereis yum|xargs rm -fr

下载rpm包

新建个目录,并进入

[root@server ~]# mkdir pyum
[root@server ~]# cd  pyum
[root@server pyum]# 

然后下载python2.7yum的依赖包:http://mirrors.163.com/centos/7/os/x86_64/Packages/
先新建一个下载链接文件

cat > filelist.txt
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-devel-2.7.5-86.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-86.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-40.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm

CTRL+C退出然后批量下载:

wget -i filelist.txt

安装

安装python2.7

rpm -ivh python-*   rpm-python-*

如果出现依赖问题,--nodeps --force为不考虑依赖包,强制安装。

rpm -ivh python-*   rpm-python-* --nodeps --force

安装yum

rpm -ivh yum-*

更换阿里源

# 操作步骤
cd /etc/yum.repos.d     # 进入yum文件夹
mv CentOS-Base.repo CentOS-Base.repo.bak        # 备份原文件
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo    # 下载阿里源的文件
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo     # 安装epel repo源

清理缓存

yum clean all        # 清理缓存
yum makecache    # 重新生成缓存
yum update         # 更新

参考链接

CentOS7.2.1511卸载并重新安装python2.7及yum
centos7 重新安装python2.7及yum
CentOS 7修改yum源为阿里源
centos7安装卸载python3,pip3

Last modification:October 12th, 2019 at 03:10 pm
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment