美文网首页
Centos7编译安装Python3.10

Centos7编译安装Python3.10

作者: sunfkny | 来源:发表于2023-04-18 19:31 被阅读0次
    #!/bin/bash
    set -e
    # Extract Python minor and build version
    PYTHON_VERSION="3.10.12"
    PYTHON_MINOR_VERSION="$(echo $PYTHON_VERSION | cut -d'.' -f 2)"
    PYTHON_BUILD_VERSION="$(echo $PYTHON_VERSION | cut -d'.' -f 3)"
    DOWNLOAD_PREFIX=https://registry.npmmirror.com/-/binary/python/$PYTHON_VERSION
    # DOWNLOAD_PREFIX=https://www.python.org/ftp/python/$PYTHON_VERSION
    
    # Check if CentOS 7
    if [[ "$(rpm -E %{rhel})" == "7" ]]; then
        echo "CentOS 7 detected, install openssl11"
        yum -y install openssl11 openssl11-devel
        export CFLAGS=$(pkg-config --cflags openssl11)
        export LDFLAGS=$(pkg-config --libs openssl11)
    else
        echo "Not CentOS 7, skip openssl11"
    fi
    
    # Install dependencies
    yum -y install wget epel-release gcc zlib zlib-devel libffi libffi-devel readline-devel openssl-devel mysql-devel sqlite-devel
    
    # Download and install Python
    cd /root
    wget $DOWNLOAD_PREFIX/Python-$PYTHON_VERSION.tgz -O Python-$PYTHON_VERSION.tgz
    tar -xzf Python-$PYTHON_VERSION.tgz
    cd /root/Python-$PYTHON_VERSION
    ./configure --with-ssl --enable-loadable-sqlite-extensions
    make -j$(nproc) && make altinstall
    alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.$PYTHON_MINOR_VERSION 0
    python3 -V
    
    

    相关文章

      网友评论

          本文标题:Centos7编译安装Python3.10

          本文链接:https://www.haomeiwen.com/subject/zmckjdtx.html