如何在 CentOS 5.5(64 位)上升级 Python

如何在 CentOS 5.5(64 位)上升级 Python

我相信我在 CA AppLogic 3.0 上运行 CentOS 5.5(64 位)。

uname -a

Linux LINUX64 2.6.18-194.32.1.el5xen #1 SMP Wed Jan 5 18:44:24 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

我已经升级了yum upgrade,但我的Python仍然是2.4.3版本。

yum info python

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.5ninesolutions.com
 * extras: mirrors.cmich.edu
 * updates: mirror.5ninesolutions.com
Installed Packages
Name       : python
Arch       : x86_64
Version    : 2.4.3
Release    : 46.el5
Size       : 72 k
Repo       : installed
Summary    : An interpreted, interactive, object-oriented programming language.
URL        : http://www.python.org/
License    : PSF - see LICENSE
Description: Python is an interpreted, interactive, object-oriented programming
           : language often compared to Tcl, Perl, Scheme or Java. Python
           : includes modules, classes, exceptions, very high level dynamic data
           : types and dynamic typing. Python supports interfaces to many system
           : calls and libraries, as well as to various windowing systems (X11,
           : Motif, Tk, Mac and MFC).
           :
           : Programmers can write new built-in modules for Python in C or C++.
           : Python can be used as an extension language for applications that
           : need a programmable interface. This package contains most of the
           : standard Python modules, as well as modules for interfacing to the
           : Tix widget set for Tk and RPM.
           :
           : Note that documentation for Python is provided in the python-docs
           : package.

我想我曾经在某个地方读到过yum依赖于python,所以我不应该删除它。那么我应该下载 python 版本 2.7.x 作为源代码并编译它吗?或者有没有办法(以某种方式)升级 Python yum

我计划对 Django 使用 Python 的最新版本 2.x。

答案1

python26可用的包epel 仓库。这应该是比手动安装更好、更简单的选择。

然而,请注意,您可能无法python用 2.6 或任何其他版本替换默认版本,因为有很多东西是为 2.4 构建的,升级它将需要您重建大量的软件包,而最终的系统将不是真正的 CentOS 5。我认为升级到 CentOS 6 比重建那么多软件包更容易。

答案2

是的,从源代码编译它:

yum install gcc gcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 zlib*.x86_64

安装 python 2.7

wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
tar -xvjf Python-2.7.tar.bz2
cd Python*
./configure --prefix=/opt/python27
make
make install
vi ~/.bash_profile

replace PATH=$PATH:$HOME/bin
with PATH=$PATH:$HOME/bin:/opt/python27/bin

重新加载 .bash_profile

source ~/.bash_profile
echo "/opt/python27/lib" > /etc/ld.so.conf.d/python27.conf
ldconfig

相关内容