Centos 系统更新Python

我现在使用的Server是CentOS release 5.4 (Final),但是Python还是2.4.3,比较低了,一直想更新一下。上次强行把Python卸载,导致yum和一些基本的命令用不了了。所以更新千万不要把老版本卸载了,新老版本可以共存的。

在几个外国论坛找到了一些资料,执行下面的命令安装2.6版本的Python:

$rpm -Uvh http://yum.chrislea.com/centos/5/i386/chl-release-5-3.noarch.rpm
$rpm  --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CHL
$rpm -Uvh  http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
$yum install libffi
$yum install python26

最后顺利完成,结果如下:

$ python26
Python 2.6.2 (r262:71600, Sep  8 2009, 13:06:43)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

这其中也遇到一个错误:

python26-2.6.2-2.i386 from chl has depsolving problems
  --> Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)
Error: Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)

这是因为没有安装程序依赖的libffi,执行第3和第4行命令安装libffi后,问题解决。

本文独立博客链接:http://lloydsheng.com/2010/05/how-to-update-python-in-centos.html

原文地址:https://www.cnblogs.com/lloydsheng/p/1726140.html