Centos6.5中实现python2与

发布时间:2019-09-25 08:24:51编辑:auto阅读(1704)

    linux下python的安装

    安装步骤如下

    1 准备编译环境

       yum groupinstall 'Development Tools'

       yum install zlib-devel bzip2-devel  openssl-devel ncurses-devel sqlite-devel sqlit

    2 下载 Python3.5代码包

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

    3 编译

        tar Jxvf  Python-3.5.2.tar.xz

        cd Python-3.5.2

        ./configure --prefix=/usr/local/python3

        make && make install

    4 设置环境变量

        echo 'export PATH=$PATH:/usr/local/python3/bin' >> ~/.bashrc

    5 设置目录(这样做的目的是在系统任意目录敲入python3调用的是python3.5的命令)

        mv /usr/bin/python /usr/local/python.bak

        rm -rf /usr/local/python2 

        ln -sv  /usr/local/python2.6  /usr/bin/python2

        ln -sv  /usr/local/python3/bin/python3.5 /usr/bin/python

    6 修改yum脚本,使其指向旧版本的python,已避免yum无法运行

       sed -i 's$#!/usr/bin/python$#!/usr/bin/python2.6$g' /usr/bin/yum

    7 测试

      输入python 显示如下

    wKioL1mmh4vDrtwaAAAiEiQNoz0936.png-wh_50

    wKiom1mmh6CB9R02AAAiTVNEqtE337.png-wh_50


关键字