美文网首页
Linux下python的安装

Linux下python的安装

作者: w_dll | 来源:发表于2019-08-11 08:30 被阅读0次

    安装步骤

    #1 新建下载目录,下载
    cd /home && mkdir soft && cd soft
    wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
    
    #2 解压文件
    chmod +x * && tar -zxvf Python-3.7.2.tgz
    
    #3 安装依赖
    #---ubunt---
    apt-get -y install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev 
    libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev 
    liblzma-dev libffi-dev libc6-dev
    #---centos---
    yum install yum-utils
    yum-builddep python
    
    #4 指定安装目录
    cd Python-3.7.2
    ./configure --prefix=/usr/local/bin/python3.7
    
    #5 编译安装
    make
    make install
    

    * 切换版本

    #切换至python3
    update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    update-alternatives --install /usr/bin/python python /usr/bin/python3 150
    
    #切换回python2
    update-alternatives --config python
    
    #centos
    ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
    

    * 安装pip及组件

    #python2
    apt-get -y install python-pip
    apt-get -y install build-essential python-dev python-setuptools
    #python3
    apt-get -y install python3-pip
    apt-get -y install build-essential python3-dev  python3-setuptools
    

    相关文章

      网友评论

          本文标题:Linux下python的安装

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