欢迎来到李先生的博客

深山的鹿,不知归处;万般皆苦,只可自渡。
扩大
缩小

Linux下安装Python3

直接上脚本,哈哈

#!/bin/bash

#FileName: python2_2_3.sh
#Date: 20190514
#Author: LiLe
#Contact: 836217653@qq.com
#Version: V1.0
#Description: Centos7下python2升级成Python3

download(){ 
    yum install wget zlib* gcc* opensslopenssl-devel    
    wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
    xz -d Python-3.7.3.tar.xz
    tar -xvf Python-3.7.3.tar
}

compile(){
    yum install -y libffi libffi-devel
    cd Python-3.7.3
    ./configure --prefix=/usr/local/python3 --with-ssl --enable-shared
    make && make install
}

create_link(){
    ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    echo "/usr/local/python3/lib" >/etc/ld.so.conf.d/python3.conf
    ldconfig
    python3 --version
}

main(){
    download
    compile
    create_link
}

main

 

posted on 2019-12-24 16:38  Captain_Li  阅读(535)  评论(0编辑  收藏  举报

导航