美文网首页
Centos7安装Pyhton3

Centos7安装Pyhton3

作者: andforce | 来源:发表于2019-01-31 11:21 被阅读7次

    安装编译工具

    yum -y groupinstall "Development tools"
    
    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
    
    yum install libffi-devel -y
    

    下载python源码,并解压

    wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
    
    tar -xvJf  Python-3.7.0.tar.xz
    

    编译

    mkdir /usr/local/python3
    
    cd Python-3.7.0
    
    ./configure --prefix=/usr/local/python3
    
    make && make install
    

    创建软连接

    ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
    
    ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
    

    验证是否成功

    python3 -V
    
    pip3 -V
    

    Python2和Python3共存

    1.查看当前python版本

    python -V
    

    Python 2.6.6

    2.备份当前python版本

    mv /usr/bin/python /usr/bin/python2.6.6
    

    3.简历python软连接

    which python3
    

    /usr/local/bin/python3

    ln -s /usr/local/bin/python3 /usr/bin/python
    

    4.校验版本

    python -V
    

    Python 3.7.0

    5.修改yum
    vi /usr/bin/yum #将文件头部的#!/usr/bin/python 改成#!/usr/bin/python2.6.6

    相关文章

      网友评论

          本文标题:Centos7安装Pyhton3

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