原始安装好的redhat6.4上的python版本是2.6.6,不能满足实际需要。升级的方法很多,从源码升级或者从rpm包升级。其中从rpm包升级相对简单。这里记录全部过程如下。准备新安装的RHEL6.4,没有安装任何其他多余的软件,配置好ISO作为本地YUM源。看看升级过程如下:
wget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/python27-libs-2.7.3-6.2.el6.nux.x86_64.rpm wget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/python27-2.7.3-6.2.el6.nux.x86_64.rpm wget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/tkinter27-2.7.3-6.2.el6.nux.x86_64.rpm wget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/python27-devel-2.7.3-6.2.el6.nux.x86_64.rpm
wget -c --no-check-certificate ftp://ftp.pbone.net/mirror/dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ -- expat2-2.0.1-1.ius.el5.x86_64.rpm -- python27-2.7.3-19.ius.el5.x86_64.rpm -- python27-libs-2.7.3-19.ius.el5.x86_64.rpm -- tkinter27-2.7.3-19.ius.el5.x86_64.rpm -- python27-devel-2.7.3-19.ius.el5.x86_64.rpm
# rpm -ivh python27-libs-2.7.3-6.2.el6.nux.x86_64.rpm # rpm -ivh python27-2.7.3-6.2.el6.nux.x86_64.rpm # yum install tix # rpm -ivh tkinter27-2.7.3-6.2.el6.nux.x86_64.rpm # rpm -ivh python27-devel-2.7.3-6.2.el6.nux.x86_64.rpm
# python2.7 -c "import zlib, sqlite3 ssl"
这个是对文件目录变化实时监控的组件。python-inotify 依赖 pathlib。
$ wget --no-check-certificate https://pypi.python.org/packages/source/p/pathlib/pathlib-1.0.1.tar.gz $ wget --no-check-certificate https://bitbucket.org/JanKanis/python-inotify/get/2193c8bdeb3b.zip
# yum install gcc-c++
# python2.7 setup.py build # python2.7 setup.py install
需要把./inotify/_inotify.c的开头添加下面的代码:
/* _inotify.c */ ... /* Exclude events on unlinked objects. */ #ifndef IN_EXCL_UNLINK # define IN_EXCL_UNLINK 0x04000000 #endif然后执行:
# python2.7 setup.py build # python2.7 setup.py install
# python2.7 examples/simple.py
在/tmp下面写个文件看看!
--------------------------------------------------------------------------------------
如果升级之后, yum不可用,可以rpm安装python2.6.6, 参考:
http://www.linuxidc.com/Linux/2013-05/84727.htm