posts - 38, comments - 13, trackbacks - 0, articles - 0
  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Linux下安装IPython及readline

Posted on 2009-12-29 13:32 大源 阅读(12084) 评论(3)  编辑 收藏 引用 所属分类: Python

1、安装准备

安装IPython之前,需要注意的是,一定要找对应Python版本的IPython版本,比如笔者的是Python2.6,相对应的IPython版本为0.10。

2、安装过程

[root@localhost Python]# tar -zxvf ipython-0.10.tar.gz
[root@localhost Python]# cd ipython-0.10
[root@localhost ipython-0.10]# python setup.py install
[root@localhost ipython-0.10]# which ipython
/usr/local/bin/ipython
[root@localhost ipython-0.10]# ipython
**********************************************************************
Welcome to IPython. I will try to create a personal configuration directory
where you can customize many aspects of IPython's functionality in:

/root/.ipython
Initializing from configuration: IPython/UserConfig

Successful installation!

Please read the sections 'Initial Configuration' and 'Quick Tips' in the
IPython manual (there are both HTML and PDF versions supplied with the
distribution) to make sure that your system environment is properly configured
to take advantage of IPython's features.

Important note: the configuration system has changed! The old system is
still in place, but its setting may be partly overridden by the settings in
"~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
if some of the new settings bother you.


Please press <RETURN> to start IPython.RETURN
**********************************************************************
Python 2.6 (r26:66714, Dec 29 2009, 12:59:14)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]:

证明已经安装成功了,接下来我们就安装ReadLine

python的readline模块是GNU Readline Library的一个封装,Readline 软件包是一个提供命令行编辑和历史纪录功能的库集合。
如果没有readline模块的话,运行ipython就是这样,无法使用Tab键自动补全,无法使用命令历史功能来方便地进行程序的调试

Python的ReadLine的安装:

1、下载readline

http://ipython.scipy.org/dist/readline-2.5.1.tar.gz 

2、安装readline

[root@localhost Python]# tar -zxvf readline-2.5.1.tar.gz
[root@localhost Python]# cd readline-2.5.1
[root@localhost readline-2.5.1]# ls       
ez_setup  Modules  PKG-INFO  readline.egg-info  rl  setupegg.py  setup.py

[root@localhost readline-2.5.1]# python setup.py install

---------------------------------------------------------------------------
This script requires setuptools version 0.6a8 to run (even to display
help).  I will attempt to download it for you (from
http://cheeseshop.python.org/packages/2.6/s/setuptools/), but
you may need to enable firewall access for this script first.
I will start the download in 15 seconds.
//这里提示要安装setuptools

我们再去下载setuptools,下载地址为:
setuptools-0.6c11.tar.gz,或者setuptools-0.6c11-py2.6.egg,我这里使用的是setuptools-0.6c11.tar.gz

[root@localhost Python]# tar -zxvf setuptools-0.6c11.tar.gz
[root@localhost Python]# ls
ipython-0.10-py26.noarch.rpm  readline-2.5.1.tar.gz
ipython-0.10.tar.gz           setuptools-0.6c11
Python-2.6.tar.bz2            setuptools-0.6c11-py2.6.egg
Python-3.1.tar.bz2            setuptools-0.6c11.tar.gz
readline-2.5.1

[root@localhost Python]# cd setuptools-0.6c11

[root@localhost setuptools-0.6c11]# ls
api_tests.txt    pkg_resources.py   setuptools           version.dat
easy_install.py  pkg_resources.txt  setuptools.egg-info  virtual-python.py
EasyInstall.txt  README.txt         setuptools.txt       wikiup.cfg
ez_setup.py      release.sh         site.py
launcher.c       setup.cfg          tests
PKG-INFO         setup.py           version

[root@localhost setuptools-0.6c11]# python setup.py install
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/local/lib/python2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.6 script to /usr/local/bin

Installed /usr/local/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11    //表示基本上setuptools已经安装成功了

//我们接下来再来安装readline
[root@localhost Python]# cd readline-2.5.1
[root@localhost readline-2.5.1]# ls
ez_setup  Modules  PKG-INFO  readline.egg-info  rl  setupegg.py  setup.py

[root@localhost readline-2.5.1]# python setup.py install
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_ext
building 'readline' extension
gcc -pthread -shared build/temp.linux-i686-2.6/Modules/readline.o readline/libreadline.a readline/libhistory.a -lncurses -o build/lib.linux-i686-2.6/readline.so
gcc: readline/libreadline.a:没有那个文件或目录
gcc: readline/libhistory.a:没有那个文件或目录
error: command 'gcc' failed with exit status 1

[root@localhost readline-2.5.1]# import readline
[root@localhost readline-2.5.1]#                      /这样子貌似成功了吧,可是上面的错误让我有点的担心。





Feedback

# re: Linux下安装IPython及readline  回复  更多评论   

2010-07-21 16:04 by xingxing
你最后的一步readline因该是没有安装成功的, 我也遇到和你相同的问题,结果我yum install 了 readline 和readline-devel,然后编辑 python源码目录下的Module/Setup文件,里面打开 了readline模块和zlib模块(zlib是我个人遇到的问题),重新编译安装python,再安装完setuptools和ipython后问题得到解决。

# re: Linux下安装IPython及readline  回复  更多评论   

2011-03-10 13:27 by pythonlearner
我也遇到和你一样的问题, 进入到readline目录下, ./confiure make make install后.再执行上述步骤就ok了
只有注册用户登录后才能发表评论。