zoukankan      html  css  js  c++  java
  • RedHat升级Python到2.7.6

    今天本来想研究一下Python  paramiko模块,安装安装 paramiko-1.10.1.tar.gz的时候报错,!看了一下虚拟机RedHat中的python,发现还是原生的2.4.3,所以决定升级一下

    [root@linuxidc ~]# python
     Python 2.4.3 (#1, May  5 2011, 16:39:10)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    [root@linuxidc ~]#

    1.下载z最新版本的python

    [root@linuxidc ~]# wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tgz

    2.解压及编译

    [root@linuxidc ~]# tar xvf Python-2.7.2.tar.bz2
    [root@linuxidc Python-2.7.6]# ./configure --prefix=/usr/local/python27
    [root@linuxidc Python-2.7.6]# make
    [root@linuxidc Python-2.7.6]# make install

    [root@linuxidc Python-2.7.6]# ls /usr/local/python27/ -al
    total 28
    drwxr-xr-x  6 root root 4096 Mar 21 01:01 .
    drwxr-xr-x 13 root root 4096 Mar 21 01:01 ..
    drwxr-xr-x  2 root root 4096 Mar 21 01:01 bin
    drwxr-xr-x  3 root root 4096 Mar 21 01:01 include
    drwxr-xr-x  4 root root 4096 Mar 21 01:01 lib
    drwxr-xr-x  3 root root 4096 Mar 21 01:01 share

    3.覆盖原有的python链接

    [root@linuxidc Python-2.7.6]# mv /usr/bin/python /usr/bin/python_old
    [root@linuxidc Python-2.7.6]# ln -s /usr/local/python27/bin/python /usr/bin/
    [root@linuxidc Python-2.7.6]# python
    Python 2.7.6 (default, Mar 21 2014, 01:00:09) 
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

    此时已经可以正常使用python2.7了,但是因为yum是使用的2.4的版本来用的,现在输入一下yum就会报错

    [root@linuxidc Python-2.7.6]# yum
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

      No module named yum

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    It's possible that the above module doesn't match the
    current version of Python, which is:
    2.7.6 (default, Mar 21 2014, 01:00:09) 
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]

    If you cannot solve this problem yourself, please go to 
    the yum faq at:
      http://wiki.linux.duke.edu/YumFaq

    5.修改yum

    [root@linuxidc Python-2.7.6]# vim /usr/bin/yum

    #!/usr/bin/python  #修改此处为2.4的位置

    [root@linuxidc Python-2.7.6]# vim /usr/bin/yum

    #!/usr/bin/python2.4

    yum 可以使用了!

    [root@linuxidc Python-2.7.6]# yum
    Loaded plugins: rhnplugin, security
    You need to give some command
    usage: yum [options] COMMAND

    List of Commands:

    check-update  Check for available package updates
    clean          Remove cached data
    deplist        List a package's dependencies
    erase          Remove a package or packages from your system
    groupinfo      Display details about a package group
    groupinstall  Install the packages in a group on your system
    grouplist      List available package groups
    groupremove    Remove the packages in a group from your system
    help          Display a helpful usage message
    info          Display details about a package or group of packages
    info-security  Returns security data for the packages listed, that affects your system
    install        Install a package or packages on your system
    list          List a package or groups of packages
    list-security  Returns security data for the packages listed, that affects your system
    localinstall  Install a local RPM
    makecache      Generate the metadata cache
    provides      Find what package provides the given value
    reinstall      reinstall a package
    repolist      Display the configured software repositories
    resolvedep    Determine which package provides the given dependency
    search        Search package details for the given string
    shell          Run an interactive yum shell
    update        Update a package or packages on your system
    update-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your system
    upgrade        Update packages taking obsoletes into account


    options:
      -h, --help            show this help message and exit
      -t, --tolerant        be tolerant of errors
      -C                    run entirely from cache, don't update cache
      -c  [config file]    config file location
      -R  [minutes]        maximum command wait time
      -d  [debug level]    debugging output level
      --showduplicates      show duplicates, in repos, in list/search commands
      -e  [error level]    error output level
      -q, --quiet          quiet operation
      -v, --verbose        verbose operation
      -y                    answer yes for all questions
      --version            show Yum version and exit
      --installroot=[path]  set install root
      --enablerepo=[repo]  enable one or more repositories (wildcards allowed)
      --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
      -x [package], --exclude=[package]
                            exclude package(s) by name or glob
      --disableexcludes=[repo]
                            disable exclude from main, for a repo or for
                            everything
      --obsoletes          enable obsoletes processing during updates
      --noplugins          disable Yum plugins
      --nogpgcheck          disable gpg signature checking
      --disableplugin=[plugin]
                            disable plugins by name
      --enableplugin=[plugin]
                            enable plugins by name
      --skip-broken        skip packages with depsolving problems
      --security            Include security relevant packages
      --cve=CVE            Include packages needed to fix the given CVE
      --bz=BZ              Include packages needed to fix the given BZ
      --advisory=ADVISORY  Include packages needed to fix the given advisory
    [root@linuxidc Python-2.7.6]#

  • 相关阅读:
    八、比卦
    七、师卦
    六、讼卦
    五、需卦
    力扣-两数之和
    什么是3NF (范式) ?
    SQL事务4个特性
    什么是索引?
    假设把只包含01的数组(如{0,0,1,1,1,0,1,0,0,1})按照升序排序,可以任意交换两个数的位置,请输出最少需要交换的次数。
    找规律并用编程实现如下数列(数值超过10000停止打印) 1,1,2,2,3,2,5,4,8,8
  • 原文地址:https://www.cnblogs.com/name/p/4920175.html
Copyright © 2011-2022 走看看