一,安装python3.9.1

参考文章

https://www.cnblogs.com/xiujin/p/11477419.html

在root用户下(不要用普通用户,麻烦)

yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y

直接使用wget下载安装包。(wget下载慢,尝试过使用mwget,但是不稳定。所以慢点就慢点)

wget wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz

解压

tar -xvJf  Python-3.9.1.tar.xz

创建编译安装目录

mkdir /usr/local/python3

安装

cd Python-3.9.1
./configure --prefix=/usr/local/python3 --with-ssl
make && make install

创建软链接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

验证是否成功

python3 -V
pip3 -V