下载:CNPM Binaries Mirror
https://cdn.npmmirror.com/binaries/python/3.11.6/Python-3.11.6.tgz
安装相关依赖
yum install zlib-devel bzip2-devel libffi-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
安装
tar -zxvf Python-3.11.6.tgz
cd Python-3.11.6;
./configure prefix=/usr/local/python3make && make install
#因此我们可以添加软链到执行目录下/usr/bin
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
执行
python -V
看看输出的是不是python3的版本
因为执行yum需要python2版本,所以我们还要修改yum的配置,否则yum操作会报错,
执行下面的命令
vim /usr/bin/yum
把#! /usr/bin/python修改为#! /usr/bin/python2
执行下面的命令
vi /usr/libexec/urlgrabber-ext-down
把文件里面的#! /usr/bin/python 也要修改为#! /usr/bin/python2
这样python3版本就安装完成;同时python2也存在