uninstall python #
优先卸载,确保环境干净
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
whereis python |xargs rm -frv
whereis python
delete yum #
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv
whereis yum
View system version #
cat /etc/redhat-release
# CentOS Linux release 7.9.2009 (Core)
Download the corresponding package from the official website or other mirror sites (recommended, fast)
install python
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
install yum
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh --nodeps http://vault.centos.org/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
There are no enabled repos.Run “yum repolist all #
yum repolist all
如果没有安装任何源,说明没有配置
mkdir /etc/yum/repos.d/
编辑/etc/yum/repos.d/fedora-163.repo
# vim /etc/yum/repos.d/fedora-163.repo
[fedora]
name=Fedora 17 - $basearch - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/$basearch/os/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-17&arch=$basearch
enabled=1
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[fedora-debuginfo]
name=Fedora 17 - $basearch - Debug - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/$basearch/debug/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-debug-17&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[fedora-source]
name=Fedora 17 - Source - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/releases/17/Everything/source/SRPMS/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-source-17&arch=$basearch
enabled=0
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
编辑vim /etc/yum/repos.d/fedora-updates-163.repo
[updates]
name=Fedora 17 - $basearch - Updates - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/$basearch/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f17&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[updates-debuginfo]
name=Fedora 17 - $basearch - Updates - Debug - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/$basearch/debug/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-debug-f17&arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
[updates-source]
name=Fedora 17 - Updates Source - 163.com
failovermethod=priority
baseurl=http://mirrors.163.com/fedora/updates/17/SRPMS/
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-source-f17&arch=$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
安装
yum makecache