python3环境搭建

发布时间:2019-04-09 21:47:48编辑:auto阅读(1996)

    安装依赖环境

    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

    centos系统下安装

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

    安装python3

    //移动到一个合适的目录方便查找
    mkdir -p /usr/local/python3
    mv Python-3.7.1.tgz /usr/local/python3
    
    //解压包
    tar -zxvf Python-3.7.1.tgz
    
    //指定编译位置,就是当前位置
    ./configure --prefix=/usr/local/python3
    
    //安装
    make && make install
    
    //建立软链接
    ln -s  /usr/local/python3/bin/python3 /usr/bin/python3
    
    
    //.bash_profile添加查找路径
    PATH=$PATH:$HOME/bin:/usr/local/python3/bin
    
    //更新
    source ~/.bash_profile
    

    报错处理

    1. ModuleNotFoundError: No module named '_ctypes
    
     安装 yum install -y gcc
     
    2. configure: error: no acceptable C compiler found in $PATH
    
     安装  yum install -y libffi-devel 
     
    3. python链接已存在
    
     改名 mv /usr/bin/python  /usr/bin/python.bak

关键字