在 RHEL 5.5 下安装 Python 和 IPython
上周利用一周的时间学习了《A Byte of Python》,基本掌握了 Python 语言,但我作为一名系统工程师,基本告别了令人讨厌的编码工作,所以学习 Python 的主要原因除了爱好,就是想用它进行系统管理,所以我又开始读《Python for Unix and Linux System Administration》这本书,我开始尝试用 Python 来进行系统配置。工欲善其事,必先利其器!使用 Python 进行系统管理,当然首推 IPython,IPython 是一种“高级交互式Python”, 除了包含内置的交互解释器的功能(当然这个用起来感觉还是不一样地)以外还提供了一组灰常灰常有用的工具。Fernando Pérez 是 iPython 的创建者,他通过阅读《IPP and LazyPython》产生了灵感,现在他是 IPython 对象的核心开发人。在 Fernando 看来,IPython 是一种能够解决问题的高度可配置的工具。
下面我来介绍一下在 RHEL 5.5 下如何安装 Python 和 IPython。我的 RHEL 5.5 64bit 预装的是 Python 2.4.3,版本比较老,而 iPython 0.11 要求 Python 的版本至少是2.6。好在可以在一个系统上安装多个版本的 Python,前提是不要安装在同一个目录中,具体的安装配置过程如下:
- 使用 yum 安装 Python 的依赖包。
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-develsqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make - 编译安装 Python 程序包。
[root@pubservicedb ~]# tar -xvf Python-2.7.2.tar.bz2
[root@pubservicedb ~]# cd Python-2.7.2
[root@pubservicedb Python-2.7.2]# ./configure --prefix=/usr/local/python2.7 --with-threads --enable-shared
[root@pubservicedb Python-2.7.2]# make
[root@pubservicedb Python-2.7.2]# make install - 创建软连接。
[root@pubservicedb Python-2.7.2]# ln -sf /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7 - 如果运行上一步创建的软连接报函数库没有加载的错误,请配置 Python 函数库:
[root@pubservicedb Python-2.7.2]# python2.7
python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
[root@pubservicedb Python-2.7.2]# touch /etc/ld.so.conf.d/python2.7.conf
[root@pubservicedb Python-2.7.2]# echo "/usr/local/python2.7/lib/" >> /etc/ld.so.conf.d/python2.7.conf
[root@pubservicedb Python-2.7.2]# cat /etc/ld.so.conf.d/python2.7.conf
[root@pubservicedb Python-2.7.2]# ldconfig
[root@pubservicedb Python-2.7.2]# python2.7
Python 2.7.2 (default, Nov 1 2011, 14:00:46)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@pubservicedb Python-2.7.2]# - 安装 IPython 程序包。
[root@pubservicedb ~]# tar -xvf ipython-0.11
[root@pubservicedb ~]# cd ipython-0.11
[root@pubservicedb ipython-0.11]# python2.7 setup.py install
[root@pubservicedb python2.7]# ln -sf /usr/local/python2.7/bin/ipython /usr/bin/ipython
[root@pubservicedb python2.7]# ipython
Python 2.7.2 (default, Nov 1 2011, 14:00:46)
Type "copyright", "credits" or "license" for more information.IPython 0.11 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit()
[root@pubservicedb ipython]# - 大功告成!
本文使用的是源代码安装的方式来安装的 IPython,其实如果系统上安装了 setuptools,那么你可以使用 easy_install 来安装,或者直接下载 IPython 的 egg 包再配置好相关环境后直接使用。如果你对 setuptools 和 egg 包的概念不是很理解,请参考这篇文章。
相关日志:
- 2011年11月24日 -- 在 RHEL 5.5 下安装 Cognos Server (0)
- 2011年11月3日 -- 在 Mac OS X 下使用 IPython (0)
- 2011年10月25日 -- yum 命令出现“段错误”的解决方案 (0)
- 2011年10月16日 -- 在 RHEL 5.5 下应用 RHCS 实现 Oracle HA (0)
- 2011年10月10日 -- 在 RHEL 5.5 下解决 MSA2312fc 的多路径问题 (0)
- 2011年08月3日 -- RHEL 5.5 下解决 IBM DS4700 的多路径问题 (0)
Categories
- 信息世界 | IT (85)
- Certification (1)
- Database (15)
- Google (10)
- Hardware (2)
- J2EE (4)
- Network (17)
- OS (17)
- Programming (11)
- Virtualization (1)
- Webmaster (5)
- 数码先锋 | Digital (15)
- 时事评论 | Event (5)
- 时光飞驰 | News (2)
- 杂七杂八 | Mix (2)
- 流金岁月 | Life (9)
- 游戏志 | Game (13)
- 看电影 | Movie (10)
- 红魔拥趸 | ManUtd (5)
- 读书频道 | Reading (1)
- 音乐无限 | Music (5)
- 信息世界 | IT (85)
Latest Comments
- Robin 发表在《查看已经安装的 Perl 模块》
- xiaochuanjiejie 发表在《查看已经安装的 Perl 模块》
- 马继军 发表在《About Me》
- Robin 发表在《在 Cacti 下实现对 Tomcat 的监控》
- 酱油 发表在《在 Cacti 下实现对 Tomcat 的监控》
- dream 发表在《理解 pkg-config 工具》
Twitter
- Chenjunlu’s Blog: 在 MIUI 系统下开启 App2SD+ 功能 http://t.co/t6F5HiRm 2012-02-15
- Chenjunlu’s Blog: 虚拟化 hypervisor 的类型对比 http://t.co/T7hvle03 2012-01-31
- I'm at 公主岭 (Siping) http://t.co/mpEU711u 2012-01-27
- 好像又没动静了。 2012-01-09
- I'm at 宜家家居 IKEA (Dalian) http://t.co/MJWDZt3g 2012-01-07
- I'm at 中山广场 Zhongshan Circus (大连) http://t.co/MyBQWjOF 2012-01-04
- I'm at Changchun Railway Station 长春站 (长白路5号, 长春市) http://t.co/sdcmprTJ 2012-01-03
- I'm at 万达广场 (Shenyang) http://t.co/EfAqBrNn 2011-12-31
- Chenjunlu’s Blog: Liferay Portal 集群配置指南 http://t.co/ANxjlSID 2011-12-26
- I'm at 壹品星海 (Dalian, China) http://t.co/knlcVidX 2011-12-14
- I'm at 五殼日本料理 (Dalian) http://t.co/Zocw45vI 2011-12-10
- I just became the mayor of 五殼日本料理 on @foursquare! http://t.co/rfHazBzj 2011-12-10
- I'm at 壹品星海 (Dalian, China) http://t.co/hQH7xCNa 2011-12-10
- I'm at 奥林匹克广场 Olympics Square (五四路, 大连) http://t.co/BWEGsBpt 2011-12-02
- Chenjunlu’s Blog: Kindle Keyboard 上手玩 http://t.co/hhN6HoN4 2011-12-02
豆瓣生活
Foursquare Checkins
标签
Android Apache Apple Cacti CPAN Digital Signature England Excel VBA Facebook Froyo Google Gravatar HA HTC Desire httpd https IBM iPad J2EE Java JBoss Konami Linux Man Utd Oracle Perl PES2011 Playstation Premier League PSP Red Hat RHCS RHEL RMAN Rooney RSA Secure Shell SNMP South Africa 2010 ssh Windows World Cup 人生 桌游 爱电影




