標籤:
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.rpmwget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/python27-2.7.3-6.2.el6.nux.x86_64.rpmwget -c --no-check-certificate http://li.nux.ro/download/nux/dextop/el6/x86_64/tkinter27-2.7.3-6.2.el6.nux.x86_64.rpmwget -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
RHEL6.4上升級python從2.6.6到2.7.3