系统为Centos7.8,默认已经安装了Python2.7.5。
Python3和Python2可以共存,安装Python3不要卸载Python2,因为yum依赖于Python2。
刚开始不清楚,按照网上教程删除了Python2和yum。
1、删除现有Python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps whereis python |xargs rm -frv whereis python
2、删除现有的yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps whereis yum |xargs rm -frv
结果发现后面安装Python3需要yum,于是只能重装Python2和yum
1、查看本机CentOS版本
cat /etc/redhat-release
结果:CentOS Linux release 7.8.2003 (Core)
2、创建python和yum两个文件夹
mkdir /usr/local/src/python mkdir /usr/local/src/yum
3、根据上面版本7.8.2003
访问:Index of /7.8.2003/os/x86_64/Packages
下载下面文件,放到/usr/local/src/python:
dbus-python-devel-1.1.1-9.el7.x86