Centos7编译安装python3.

发布时间:2019-10-17 09:08:09编辑:auto阅读(2346)

    环境:

    CentOS Linux release 7.5.1804
    python3.7.3

    前期准备:

    安装相关依赖包,采用yum安装.

    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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2 #相应依赖包

    开始安装

    解压下载的安装包

    tar -xf Python-3.7.3.tgz #解压下载的安装包
    cd cd Python-3.7.3 #进入目录
    ./configure --enable-optimizations #编译检测
    make && make install #编译并安装

    不出意外的话应该是安装成功的,要是有报错的话需要在看看是否缺少相关依赖包或者是环境变量。

    一件下载安装脚本

    本脚本从org下载安装包,并yum安装所有依赖包,自动安装python3.7.3

    wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz &&\
    tar xf Python-3.7.3.tgz &&\
    cd Python-3.7.3 &&\
    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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2  #相应依赖包 &&\
    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 gcc gcc-c++ zlib zlib-devel libffi-devel gcc kernel-devel kenel-headers make bzip2 #防失败执行多一次 &&\
    ./configure --enable-optimizations &&\
    make && make install

关键字