• linux/centos6.5下编译安装python2.7和python3.5.2



    centos6.5环境下安装python2.7

    解压python源码包
    tar -xf Python-2.7.6.tar.xz

    进入软件包目录
    cd Python-2.7.6

    添加配置项
    ./configure --prefix=/usr/local/python27

    编译
    make

    报错

    Python build finished, but the necessary bits to build these modules were not found:
    _bsddb             _sqlite3           _ssl            
    _tkinter           bsddb185           bz2             
    dbm                dl                 gdbm            
    imageop            sunaudiodev                        
    To find the necessary bits, look in setup.py in detect_modules() for the module's name.



    centos安装盘中有相关的依赖包安装即可(readline)
    方法:
    将centos6.5的光盘挂载在/mnt/cdrom目录下
    mkdir /mnt/cdrom
    mount /dev/cdrom /mnt/cdrom
    cd /mnt/cdrom/Packages/

    提示缺少readline-devel包,安装readline-devel包的时候提示依赖ncurses-devel
     rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

     rpm -ivh readline-devel-6.0-4.el6.x86_64.rpm

    删除相关的目录重新配置并编译
    rm -rf /usr/local/python27
    ./configure --prefix=/usr/local/python27
    make
    make install
    后面继续报缺少依赖包直接忽略
    ②安装ipython1.2.1
    tar -xf ipython-1.2.1.tar.gz

    cd ipython-1.2.1

    使用python27对ipython进行编译
    /usr/local/python27/bin/python2.7 setup.py build
    编译成功执行安装
    /usr/local/python27/bin/python2.7 setup.py install


    如果安装成功则在/usr/local/python27/bin目录下有一个ipython文件
    ls /usr/local/python27/bin/


    ######################
    将python和ipython链接到bin目录下,方便调用(直接输入python和ipython命令即可)
    ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27


    ln -sv /usr/local/python27/bin/ipython /usr/bin/


    centos6.5环境python3.5的安装



    安装相关依赖:

    yum -y install xz wget gcc make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel

    安装python3:

    wget http://mirrors.sohu.com/python/3.5.2/Python-3.5.2.tar.xz

    tar -xf Python-3.5.2.tar.xz

    cd Python-3.5.2

    ./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib

    make && make install

    添加python3命令:

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

    vim /etc/ld.so.conf

    /usr/local/lib # 新增库文件路径
    include ld.so.conf.d/*.conf

    # 使配置库生效
    /sbin/ldconfig

    版本检测
    # python3 -V
    Python 3.5.2


    以后直接运行python3就可以通过python3.5.2版本执行命令了

  • 相关阅读:
    简单通讯聊天 群聊功能 Windows下的客户端 Linux下的epoll服务器
    Windows客户端 Linux服务器通讯 字符编码问题
    C++时间标准库时间time和系统时间的使用
    Window7系统安装Ubuntu16双系统
    Window7 系统下重新建立一个新分区
    UltraISO(软碟通) 制作U盘启动盘
    Python 列表反转显示方法
    HTML,CSS,JS个别知识点总结
    Git 创建版本库并实现本地上传数据到GitHub库
    Python爬虫数据保存到MongoDB中
  • 原文地址:https://www.cnblogs.com/reblue520/p/6239901.html
Copyright © 2020-2023  润新知