centos安装Python3

发布时间:2019-09-27 07:10:47编辑:auto阅读(1985)

    一、安装思路
    在不影响Python2的情况下安装Python3,做到以下几个步即可:
    1、将Python2对应的命令改名
    2、下载Python3包并且编译安装
    3、在Python命令的目录下建立软链到Python3命令
    4、修改yum与urlgrabber-ext-down 对应的Python头
    二、实际操作
    1、安装编译对应的依赖:

    yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

    2、改名Python

        cd /usr/bin
        mv python python2.bak

    3、下载并安装python3

        wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
        tar -xf  Python-3.6.2.tar.xz
        cd Python-3.6.2
        ./configure prefix=/usr/local/python3
        make && make install

    4、建立软链

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

    5、修改yum与urlgrabber-ext-down的Python头
    将#! /usr/bin/python修改为#! /usr/bin/python2

    vim /usr/bin/yum
    vim /usr/libexec/urlgrabber-ext-down

关键字