Hexo

点滴积累 豁达处之

0%

基于centos7.4 重装python和yum

基于centos7.4 重装python和yum

删除现有python和yum

1
2
3
4
5
6
7
1、删除现有Python
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
[root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
[root@test ~]# whereis python ##验证删除,返回无结果
2、删除现有的yum
[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[root@test ~]# whereis yum |xargs rm -frv

下载安装

查看系统版本信息命令

1
2
3
4
5
6
7
## lsb_release -a  查看系统版本信息命令
[root@izm5e7klp5h59pozbv3fghz nginx]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

下载资源包

下载对应版本的资源包: http://vault.centos.org/7.4.1708/os/x86_64/Packages(根据自己系统版本调整链接)

当前下载路径为: /usr/java/python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/lvm2-python-libs-2.02.171-8.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-virtualenv-1.10.1-4.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-build-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-build-libs-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-libs-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-sign-4.11.3-25.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-aliases-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-utils-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

安装

安装python

1
2
cd /usr/java/python
rpm -ivh python-* rpm-python-*

安装yum

1
2
cd /usr/java/yum
rpm -ivh yum-* libxml*

注 参数 –nodeps –force: 调过依赖,强制安装

示例: rpm -ivh yum-* –nodeps –force

修改yum源

修改yum源,在安装更新rpm包时获得比较理想的速度。国内比较快的有163源、sohu源。这里以163源为例子。

1
2
3
4
5
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo CentOS-Base.repo
yum clean all