一、彻底卸载python和yum
删除python已安装程序及其关联
删除残余python文件
验证删除,返回为无结果
删除现有yum
删除残余yum文件
使用wget下载:
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
三、解压Python3.6.8压缩包
使用tar命令解压Python3.6.8压缩包:
tar -zxvf Python-3.6.8.tgz
四、编译安装Python3.6.8
进入解压后的Python3.6.8目录,使用以下命令进行编译和安装:
./configure –prefix=/usr/local/python3.6.8
make && make install
4. 配置环境变量
将Python3.6.8的bin目录添加到系统环境变量中,使得系统能够找到Python3.6.8的执行文件。
echo 'export PATH=/usr/local/python3.6.8/bin:$PATH' >> /etc/profile source /etc/profile
5. 验证安装
执行以下命令,查看Python3.6.8的版本信息:
python3 -V
如果输出Python3.6.8的版本信息,则说明安装成功。
如果缺少依赖包
cd /usr/local/src/python wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/checkpolicy-2.9-1.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/dnf-plugins-core-4.0.21-3.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/newt-0.52.20-11.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/nftables-0.9.3-21.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/openssl-devel-1.1.1k-5.el8_5.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/platform-python-3.6.8-41.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/platform-python-pip-9.0.3-20.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/platform-python-setuptools-39.2.0-6.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/policycoreutils-2.9-16.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-asn1crypto-0.24.0-3.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-cffi-1.11.5-5.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-configobj-5.0.6-11.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-cryptography-3.2.1-5.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dateutil-2.6.1-6.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dateutil-2.6.1-6.el8.noarch.rpm.1 wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dbus-1.2.4-15.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-decorator-4.2.1-2.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dmidecode-3.12.2-15.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dnf-4.7.0-4.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-dnf-plugins-core-4.0.21-3.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-firewall-0.9.3-7.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-gobject-base-3.28.3-2.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-gpg-1.13.1-9.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-hawkey-0.63.0-3.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-idna-2.5-5.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libcomps-0.1.16-2.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libdnf-0.63.0-3.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-librepo-1.14.0-2.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libs-3.6.8-41.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libselinux-2.9-5.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libsemanage-2.9-6.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-libxml2-2.9.7-9.el8_4.2.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-linux-procfs-0.6.3-1.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-nftables-0.9.3-21.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-perf-4.18.0-348.7.1.el8_5.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-pip-wheel-9.0.3-20.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-ply-3.9-9.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-policycoreutils-2.9-16.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-pycparser-2.14-14.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-pyparsing-2.1.10-7.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-pyudev-0.21.0-7.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-rpm-4.14.3-19.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-schedutils-0.6-6.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-setools-4.3.0-2.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-setuptools-39.2.0-6.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-setuptools-wheel-39.2.0-6.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-six-1.11.0-8.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-slip-0.6.4-11.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-slip-dbus-0.6.4-11.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/python3-syspurpose-1.28.21-3.el8.x86_64.rpm rpm -Uvh --force *.rpm 缺少依赖包,安装提示到https://vault.centos.org/centos/8.5.2111/BaseOS/x86_64/os/Packages/ 去下载 cd /usr/local/src/yum wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/libdnf-0.63.0-3.el8.x86_64.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/yum-utils-4.0.21-3.el8.noarch.rpm wget https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/dnf-4.7.0-4.el8.noarch.rpm rpm -Uvh --force *.rpm
大功告成