zoukankan      html  css  js  c++  java
  • 20) 源码编译安装python2和3版本

    1- 源码编译安装python2.7版本

    1.1- 下载源码包

    wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
    

    1.2- 安装依赖包

    centos/redhat:

    yum install -y gcc zlib zlib-devel openssl openssl-devel
    

    ubuntu/debian:

    apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev  libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat-dev
    

    1.3- 解压源码包

    tar -zxvf Python-2.7.14.tgz
    

    1.4- 编译

    cd Python-2.7.14
    ./configure --enable-optimizations --prefix=/usr/local/python2.7.14
    vim Modules/Setup
    默认这块是注释的,放开注释即可。这块功能是开启SSL模块,不然会出现安装完毕后,提示找不到ssl模块的错误。
    


    修改后:

    1.5- 安装

    make && make install
    ln -s  /usr/local/python2.7.14/bin/python2.7  /usr/bin/python2.7.14
    

    1.6- 检查版本

    python2.7.14 --version
    Python 2.7.14
    

    2- 源码编译安装python3.7版本

    2.1- 下载安装包

    wget https://www.python.org/ftp/3.7.0/Python-3.7.0.tgz
    

    2.2- 解压

    tar -xvf Python-3.7.0.tgz
    

    2.3- 安装依赖包

    centos/redhat:

    yum install -y gcc zlib zlib-devel openssl openssl-devel
    

    ubuntu/debian:

    apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev  libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat-dev
    

    2.4- 编译

    cd  /Python3.7.0
    ./configure --prefix=/usr/local/python/python-3.7.0
    

    2.5- 安装

    make && make install
    ln -s /usr/local/python/python-3.7.0/bin/python3.7    /usr/bin/python3.7
    

    2.6- 检查版本

    python3.7.0 --version
    Python 3.7.0
  • 相关阅读:
    释放 Linux 系统预留的硬盘空间(转)
    内存置换空间(swap)之建置(转)
    启动挂载(转)
    硬链接与软链接(转)
    磁盘与目录的容量(转)
    linux网络相关配置文件(转)
    python资源库大全
    pikachu学习记录(二)
    pikachu学习记录(一)
    sqlmap基础用法
  • 原文地址:https://www.cnblogs.com/lemanlai/p/12325343.html
Copyright © 2011-2022 走看看