查看Python版本python -V更新yum源yum update安装依赖yum install yum-utils yum-builddep python3下载pythonwget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz安装Python相关依赖yum -y install zlib-devel bzip2-devel openssl-devel ncursesdevelsqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel安装c，c++已经安装可跳过此步骤。yum -y install gcc g++创建安装目录 mkdir /usr/local/python3解压tar xf Python-3.8.5.tgz编译cd Python-3.8.5/ /配置安装目录 ./configure --prefix=/usr/local/python3 /编译 make安装make install创建软链接ln -s /usr/local/python3/bin/python3 /usr/bin/python / 注意这样是修改Python3为默认，那么这样还需要修改yum配置，后面会提到 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip完成python3 -V pip3 -V更改yum配置(非必要)取决于你是否将python3设置为了默认，如果是可以执行下面操作。因为yum要用到python2.x，否则会导致yum不能正常使用（不管安装 python3的那个版本，都必须要做的）vim /usr/bin/yum 把 #! /usr/bin/python 修改为 #! /usr/bin/python2 vim /usr/libexec/urlgrabber-ext-down 把 #! /usr/bin/python 修改为 #! /usr/bin/python2