CentOS 7 安装 python3 之后 yum update 失败的原因和解决方案

我在之前的文章 《CentOS 安装 Python3 最佳方法》介绍了在 CentOS 上快速安装 python3 的方法,我自己的系统上也确实是用这种方式安装的。但是今天通过 yum update 更新系统的时候竟然报错了。

file /usr/lib64/python3.6/xml/sax/__pycache__/xmlreader.cpython-36.opt-2.pyc from install of python36-libs-3.6.6-5.el7.x86_64 conflicts with file from package python36u-libs-3.6.7-1.ius.centos7.x86_64
file /usr/lib64/python3.6/xml/sax/__pycache__/xmlreader.cpython-36.pyc from install of python36-libs-3.6.6-5.el7.x86_64 conflicts with file from package python36u-libs-3.6.7-1.ius.centos7.x86_64
file /usr/lib64/python3.6/xml/sax/expatreader.py from install of python36-libs-3.6.6-5.el7.x86_64 conflicts with file from package python36u-libs-3.6.7-1.ius.centos7.x86_64
file /usr/lib64/python3.6/zipfile.py from install of python36-libs-3.6.6-5.el7.x86_64 conflicts with file from package python36u-libs-3.6.7-1.ius.centos7.x86_64
file /usr/bin/python3.6m from install of python36-3.6.6-5.el7.x86_64 conflicts with file from package python36u-3.6.7-1.ius.centos7.x86_64
file /usr/bin/python3.6 from install of python36-3.6.6-5.el7.x86_64 conflicts with file from package python36u-3.6.7-1.ius.centos7.x86_64

Error Summary
-------------

从报错的信息中很容看出来是出现了冲突。经过 Google 发现原因是系统上由 epel 源(就是用 《CentOS 安装 Python3 最佳方法》这个方法时添加的),同时还有 ius 源。运行 yum repolist 就能看到当前系统添加的源:

[iplay@xx-good iplay]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id               repo name                                           status
base/7/x86_64         CentOS-7 - Base                                     10,097
epel/x86_64           Extra Packages for Enterprise Linux 7 - x86_64      13,398
extras/7/x86_64       CentOS-7 - Extras                                      304
ius/x86_64            IUS for Enterprise Linux 7 - x86_64                    387
updates/7/x86_64      CentOS-7 - Updates                                     311
repolist: 24,497

原来 epel 和 ius 源有相同的 python3 版本,而且依赖相同的文件,导致更新时出现冲突了。网上有很多方法,包括跳过 python3 的更新(难道永远不更新?)、删除某个源(epel 和 ius 源的偏好和目的不同,建议保留),还有一个方法就是卸载重装。

我决定用第三种方法:

卸载python3
      rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps       卸载pyhton3
      whereis python3 |xargs rm -frv           删除所有残余文件
      成功卸载!
      whereis   python       查看现有安装的python

————————————————
版权声明:本文为CSDN博主「lcanlup」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lcanlup/article/details/84635625

卸载完成后直接运行 yum install python3 ,系统自动安装好 python3、pip3 和其他依赖的包,输入 python3 -V 看到版本号就说明已经成功。此时运行 yum update 终于恢复到如行云流水般顺畅。

耕读君
耕读君

热爱科技,热爱折腾,有一个可爱的女儿

文章: 329

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注