RHEL6.4上升级python从2.6.6到2.7.3
原始安装好的redhat6.4上的python版本是2.6.6,不能满足实际需要。升级的方法很多,从源码升级或者从rpm包升级。其中从rpm包升级相对简单。这里记录全部过程如下。准备新安装的RHEL6.4,没有安装任何其他多余的软件,配置好ISO作为本地YUM源。看看升级过程如下:
1 升级python
1) 首先是下载python的RPM包
共4个:
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
2)然后以下面的次序安装
# 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
3) 测试是否组件可用
# python2.7 -c "import zlib, sqlite3 ssl"
2 安装python-inotify
这个是对文件目录变化实时监控的组件。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
1) python-inotify需要安装gcc-c++
# yum install gcc-c++
2) 然后进入pathlib目录,执行:
# python2.7 setup.py build # python2.7 setup.py install
3) 和JanKanis-python-inotify-2193c8bdeb3b目录
需要把./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
4) 测试python-inotify
# python2.7 examples/simple.py
在/tmp下面写个文件看看!
--------------------------------------------------------------------------------------
如果升级之后, yum不可用,可以rpm安装python2.6.6, 参考:
http://www.linuxidc.com/Linux/2013-05/84727.htm
时间: 2024-10-15 15:20:48