zoukankan      html  css  js  c++  java
  • 在RHEL5.4上升级Python

    标题: 在RHEL5.4上升级Python

    我的RHEL 5.4 64bit预装的是python2.4.3,
        cat /etc/redhat-release
        Red Hat Enterprise Linux Server release 5.4 (Tikanga)
        python --version

    想升级到python 2.7。 打算先卸载 py 2.4, 运行 rpm -e python, 报失败, 因为有很多东西依赖py2.4。 并且运行ps -ef|grep -i py, 发现还有几个进程正在使用python. 看来是不应该卸载python2.4。

    好在可以在一个机器上安装多个版本的python. 前提是不要安装在同一个目录中. 下文是将py2.7 安装在User自己目录的方法.

    python 官网上只有mac/windows的installer, 要在linux上安装, 需要下载源码, 然后使用make install安装.

    下面步骤主要是摘自: http://x.thexs.us/2011/06/16/install-python-2-7-opencv-2-2-on-a-linux-server-without-sudo/

    下面3个文章有更详尽说明:

    中文 https://www.liuze.info/?p=57
    http://willsani.com/2011/03/02/centos-5-5-x86_64-install-python-2-7/
    http://villaroad.com/2010/10/rolling-python-2-6-2-on-centos-5-3/

    前提条件:
    源码的编译和安装需要有这些程序包. yum install gcc gcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 zlib*.x86_64


    下载:
    国内是无法访问python官网的download页面, 还好ftp页面没有被封. 2.7.2版的url为,
    http://www.python.org/ftp/python/2.7.2/

    安装:
    Download and install Python 2.7
        wget http://www.python.org/ftp/python/2.7.2/Python-2.7.1.tgz
        tar xzvf Python-2.7.1.tgz
        cd Python-2.7.1
        ./configure --prefix=/home/username/local --with-threads --enable-shared --enable-profiling
        make
        make install

       
    安装后的配置:
    In order to make it work, you also need to add the following lines to your .bashrc/.bash_profile file:
        export PATH=/home/username/local/bin:$PATH
        export LD_LIBRARY_PATH=/home/username/local/lib:$LD_LIBRARY_PATH
        export PYTHONPATH=/home/username/local/lib/python2.7/site-packages:$PYTHONPATH
        alias python='home/username/local/bin/python'
        alias python24='/usr/bin/python'
       

  • 相关阅读:
    Java IO/NIO
    LeetCode—— 两两交换链表中的节点
    LeetCode——合并K个排序链表
    LeetCode第201场周赛
    LeetCode第202场周赛
    LeetCode215. 数组中的第K个最大元素
    LeetCode213. 打家劫舍 II
    LeetCode212. 单词搜索 II
    LeetCode211. 添加与搜索单词
    LeetCode210. 课程表 II
  • 原文地址:https://www.cnblogs.com/harrychinese/p/Upgrade_Python_To_27_From_24_On_Linux.html
Copyright © 2011-2022 走看看