CentOS6重装yum和python
1、首先是把yum和python删除干净
删除python rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果 删除yum rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv
whereis yum
2、下载对应包
从上面那个网址里进入自己CentOS版本的文件夹下找包 例如我的是6.10版本的:https://vault.centos.org/6.10/os/x86_64/Packages/
https://vault.centos.org/6.10/os/x86_64/Packages/
python-2.6.6-66.el6_8.x86_64.rpm python-devel-2.6.6-66.el6_8.x86_64.rpm python-iniparse-0.3.1-2.1.el6.noarch.rpm python-libs-2.6.6-66.el6_8.x86_64.rpm python-pycurl-7.19.0-9.el6.x86_64.rpm python-setuptools-0.6.10-4.el6_9.noarch.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm rpm-python-4.8.0-59.el6.x86_64.rpm yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-aliases-1.1.30-41.el6.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm yum-utils-1.1.30-41.el6.noarch.rpm
3、使用rpm安装
rpm -Uvh --replacepkgs python*.rpm --nodeps --force
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force
4、测试
yum python
没有问题,安装就完成了
5、更换yum源
另外,这里写一下yum换源,本来从网上下了阿里、163的源,结果都用不了,好像是网站换了,最后找了个 http://vault.centos.org [base] name=CentOS-6 - Base #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&?repo=os&infra=infra baseurl=http://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates [updates] name=CentOS-6 - Updates #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&?repo=updates&in…infra baseurl=http://vault.centos.org/6.10/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful [extras] name=CentOS-6 - Extras #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&?repo=extras&inf…infra baseurl=http://vault.centos.org/6.10/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages [centosplus] name=CentOS-6 - Plus #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&?repo=centosplus…infra baseurl=http://vault.centos.org/6.10/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users [contrib] name=CentOS-6 - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=6&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&?repo=contrib&in…infra baseurl=http://vault.centos.org/6.10/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 把关于版本的地方(6和6.10)改成自己的就好了 或者去试试国内哪个源矿业用替换一下baseurl就好了,注意一下路径,正常来说替换一下http://vault.centos.org好了,如果不行就加入网页去看看对应文件的网址,网页名和文件夹名都是对应的
6、下载地址:讨厌积分,这里将付上百度下载连接
链接:https://pan.baidu.com/s/1tVYHMunn_NRrM6eJrXCi1w 提取码:kdgi
7、错误检查
装好上述环境后会出现yum出错,错误如下:
[root@localhost opt]# yum install gcc 已加载插件:aliases, fastestmirror, protectbase 设置安装进程 Repository base is listed more than once in the configuration Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository contrib is listed more than once in the configuration Repository epel is listed more than once in the configuration Repository epel-debuginfo is listed more than once in the configuration Repository epel-source is listed more than once in the configuration Loading mirror speeds from cached hostfile http://mirrors.aliyun.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404 Not Found” 尝试其他镜像。 To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn’t help to resolve this issue please open a ticket with Red Hat Support.
错误:Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again
然后进入改cd /etc/yum.repos.d,把下面的文件从相同系统版本和yum功能正常的机器复制到有问题的机器上。 a. 打开/etc/yum.repos.d/xxxxx.repo,对于本例来说就是cd /etc/yum.repos.d b.ls c.vi epel.repo d. 将项[xxx]中的enabled=1改为enabled=0
然后执行yum clean all和yum makecache。
原创不易,转载请标明出处
|