CentOS7.8安装python3.11

CentOS7.8安装python3.11

这里使用python源码包3.11.2安装。

  1. 需要能连接外网
  2. 需要配置在线yum源

首先安装包下载python3.11.2.tgz
执行:

tar zxvf python3.11.2.tgz
cd python3.11.2 && sh python311_install.sh

然后等待安装完成即可



python311_install.sh

#!/bin/bash

# You should have Internet connection.
# You should have Online yum resource, if you don't have Online yum resource, Please use below

function online_yumresource() {
    
    
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
}

function py311_install() {
    
    
yum -y groupinstall "Development tools"
yum install -y ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel uuid-devel readline-devel bzip2-devel libffi-devel
yum install -y openssl-devel openssl11 openssl11-devel
yum install centos-release-scl
yum -y install devtoolset-8
source /opt/rh/devtoolset-8/enable
echo "source /opt/rh/devtoolset-8/enable" >> /etc/profile
gcc --version

export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)
tar zxvf Python-3.11.2.tgz
cd Python-3.11.2
./configure --enable-optimizations
make && make altinstall
ln -sf /usr/local/bin/python3.10 /usr/bin/python3
ln -sf /usr/local/bin/pip3.10  /usr/bin/pip3
mkdir -p ~/.pip
cat > ~/.pip/pip.conf << 'eof'
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
        http://pypi.douban.com/simple/
        http://mirrors.aliyun.com/pypi/simple/
#proxy = [user:passwd@]proxy.server:port
[install]
trusted-host=
        pypi.tuna.tsinghua.edu.cn
        pypi.douban.com
        mirrors.aliyun.com
ssl_verify: false
eof
pip3 install --upgrade pip
}
py311_install

猜你喜欢

转载自blog.csdn.net/qq_46480020/article/details/129430199