美文网首页
CentOS 7 下安装 python3

CentOS 7 下安装 python3

作者: iOS不高级工程师王老师 | 来源:发表于2019-01-14 09:52 被阅读9次

    安装基本环境(主要是这步,否则后面会出很多问题)

    sudo 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
    

    安装python3

    sudo mkdir /usr/local/python3
    
    //下载python3
    wget --no-check-certificate https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
    
    //解压缩
    tar -xzvf Python-3.6.2.tgz
    
    cd Python-3.6.2/
    
    //编译
    sudo ./configure --prefix=/usr/local/python3
    
    sudo make
    sudo make install
    
    //建立软连接
    sudo ln -s /usr/bin/python3/bin/python3 /usr/bin/python3
    
    //参考
    并将/usr/local/python3/bin加入PATH
    
    # vim ~/.bash_profile
    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    # User specific environment and startup programs
    PATH=$PATH:$HOME/bin:/usr/local/python3/bin
    export PATH
    
    //生效
    source ~/.bash_profile
    
    

    测试

    终端输入查看版本信息
    python3
    pip3
    

    如果pip无效 安装 pip

    //下载pip
    wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz
    
    //解压缩
    tar -xzvf 9.0.1.tar.gz
    
    cd pip-9.0.1/
    python3 setup.py install
    
    

    相关文章

      网友评论

          本文标题:CentOS 7 下安装 python3

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