今天本来想研究一下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]#

RedHat升级Python到2.7.6的更多相关文章

  1. 什么是Python?Python的设计哲学?如何获取/升级Python?

    Python? Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/) Python的创始人为吉多·范罗苏姆(Guido van Rossum). 1989年的圣诞节期间,吉多· ...

  2. RHEL6.4上升级python从2.6.6到2.7.3

    RHEL6.4上升级python从2.6.6到2.7.3 原始安装好的redhat6.4上的python版本是2.6.6,不能满足实际需要.升级的方法很多,从源码升级或者从rpm包升级.其中从rpm包 ...

  3. linux centos系统下升级python版本

    本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...

  4. 升级 python 2.6.6 系统到 2.7.10 版本

    CentOS 6 系统默认 Python 版本是:2.6.6 平时在使用中遇到很多的库要求是 2.7.x 版本的库,比如使用 ConfigParser 库,在 2.6 版本库就不支持没有 value ...

  5. Linux 下编译升级 Python

    一.Centos下升级python3.4.3 1.下载安装 wget http://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz wget http ...

  6. centos6.5升级python为2.7

    今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz.setuptools-14.3.1. ...

  7. 升级python到2.7版本pip不可用

    升级python到2.7版本pip不可用 [root@localhost pip-7.1.2]# pip Traceback (most recent call last): File "/ ...

  8. CentOS 6.5升级Python和安装IPython

    <转自:http://www.noanylove.com/2014/10/centos-6-5-sheng-ji-python-he-an-zhuang-ipython/>自己常用.以做备 ...

  9. 解决删除/升级Python导致Ubuuntu无法进入桌面的问题

    找到问题的原因后于是换个思路,想大概修复了python,Ubuntu进入桌面应该也就没啥问题了.于是重新安装Python发现还是无济于事.也通过/usr/bin/python: can't find ...

随机推荐

  1. Ubuntu下使用网易云音乐

    Ubuntu15真心各种崩溃啊 最后决定还是换成ubuntu14.04LTS了 在win.android平台上网易云音乐好用到爆 ubuntu下没有网易云音乐的客户端怎么能行 https://gith ...

  2. 如何才能通俗易懂的解释javascript里面的"闭包"?

    看了知乎上的话题 如何才能通俗易懂的解释javascript里面的‘闭包’?,受到一些启发,因此结合实例将回答中几个精要的答案做一个简单的分析以便加深理解. 1. "闭包就是跨作用域访问变量 ...

  3. (原创)(三)机器学习笔记之Scikit Learn的线性回归模型初探

    一.Scikit Learn中使用estimator三部曲 1. 构造estimator 2. 训练模型:fit 3. 利用模型进行预测:predict 二.模型评价 模型训练好后,度量模型拟合效果的 ...

  4. PHP上传大文件配置

    使用PHP上传比较大的文件时,发现程序没反应,那是因为PHP的默认设置限制了上传文件的大小,所以要修改配置文件php.ini中的一些选项:(以下只是我个人的配置,大家可根据自己的实际需要配置) fil ...

  5. Memcached理解

    一.Memcached简介: 1. Memcached是一个自由开源的,高性能的,分布式内存对象缓存系统. 2. Memcached是一种基于内存的key-value存储,用来存储小块的任意数据(字符 ...

  6. Linux系列教程(九)——Linux常用命令之网络和关机重启命令

    前一篇博客我们讲解了Linux压缩和解压缩命令,使用的最多的是tar命令,因为现在很多源码包都是.tar.gz的格式,通过 tar -zcvf 能完成解压.然后对于.zip格式的文件,使用gunzip ...

  7. SIP简介,第1部分:SIP初探

    说明:以下内容来着之前下载的一份文档,现将概念部分摘录在BLog,完成文档将放在文件中. SIP简介,第1部分:SIP初探 时间:2006-04-07作者:Emmanuel Proulx浏览次数: 2 ...

  8. 1.Nginx 简介

    Nginx是Apache服务器不错的替代品,它能支持高达50 000个并发连接数的响应,而内存,CPU等系统资源消耗却非常低,运行非常稳定. 1.选择Nginx的理由 1.1 可以高并发连接 1.2 ...

  9. L2-2. 链表去重

    L2-2. 链表去重 时间限制300 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者陈越给定一个带整数键值的单链表L,本题要求你编写程序,删除那些键值的绝对值有重复的 ...

  10. 蓝桥杯-算法训练--ALGO-4 结点选择

    本人是一个刚刚接触C++不久的傻学生~记录一些自己的学习过程.大神路过可以批评指正~ 刚学动态规划,水平还很渣,一下子不知道从何下手,借鉴了一下这位大哥的文章 http://www.cnblogs.c ...