centos7编译安装升级python3.11

编译安装python3.11

      • 准备步骤
      • 解压编译
      • 替换升级

准备步骤

yum -y install gcc zlib zlib-devel libffi libffi-devel bzip2-devel
yum -y install openssl-devel openssl11 openssl11-devel
yum -y install readline-devel

解压编译

wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz
tar -zxvf Python-3.11.3.tgz
# 设置环境变量指定openssl
export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)
# 切换目录
cd Python-3.11.3
# 配置
./configure --prefix=/usr/local/python3 --with-ssl
# 编译、安装
make && make install

替换升级

cd /usr/bin/
# 取消软链
unlink python3
# 替换
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# 更新pip
mv pip3 pip3-bak
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
/usr/local/python3/bin/python3.11 -m pip install --upgrade pip
# 安装依赖(推荐)
/usr/local/python3/bin/python3.11 -m pip install alibabacloud_bssopenapi20171214==2.0.10

你可能感兴趣的:(python,python3.11)