一 将官网下载的安装包解压到centos7中
二 安装依赖
yum -y install make gcc gcc-c++
yum -y install make gcc gcc-c++
yum -y install zlib*
yum -y install readline-devel
yum install -y openssl openssl-devel
yum install -y libffi-devel
yum install -y libsqlite3x.x86_64
yum install -y libsqlite3x-devel.x86_64
yum install -y sqlite.x86_64
yum install -y sqlite-devel.x86_64
三 创建安装目录
mkdir /usr/local/python396
四 安装
# 进入解压后的安装包文件夹内
cd /usr/local/Python-3.9.6
# --prefix用来指定安装的目录,也就是上一步已创建的目录/usr/local/python396
./configure --prefix=/usr/local/python396
make && make install
五 安装测试
./python3 -V