ipython缺少tab提示功能(附readline安装之gcc错误)解决方法
System:Ubuntu10.04+LXDE
Python:2.5
Ipython:0.10
每天开发总是遇到一些稀奇古怪的事情,比如昨天配置安装完iPython,发现没有TAB自动提示及相关的颜色配置
原来是Python没有安装Readline模块,然后去下载最新的readline模块
http://pypi.python.org/pypi/readline#downloads
最新版6.1.0
使用python2.5 setup.py install安装,它会自调用Gcc编译安装,安装最后居然出现错误,如下:
===========Error===================
以上略....
gcc -pthread -shared build/temp.linux-i686-2.5/Modules/2.x/readline.o readline/libreadline.a readline/libhistory.a -lncurses -o build/lib.linux-i686-2.5/readline.so
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
===========End Error===============
查找发现原来是缺少ncurses库,没办法,继续下载ncurses
http://ftp.gnu.org/pub/gnu/ncurses/
我选择最后一个5.7的版本下载,编译安装:
./configure
make
make install
编译通过,
继续安装readline,执行python2.5 setup.py install
Ok~一切顺利,如下:
====================Ok================================
Adding readline 6.1.0 to easy-install.pth file
Installed /usr/local/lib/python2.5/site-packages/readline-6.1.0-py2.5-linux-i686.egg
Processing dependencies for readline==6.1.0
Finished processing dependencies for readline==6.1.0
=====================End Ok============================
打开iPython,熟悉的界面颜色及TAB回来啦~
======分享技巧==========
另附一个在Python原shell中实用的操作(摘自书籍“可爱的python” Ipython一章)
[利用readline和
rlcompleter模块,完成
Tab自动补全功能]
翠花,上代码。。。
alex@alex-pc:/usr/local/bin$ python2.5
Python 2.5.2 (r252:60911, Oct 10 2010, 17:22:23)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rlcompleter
>>> import readline
>>> readline.parse_and_bind('tab:complete')
>>> h
hasattr hash help hex
============-==========
暂时没有评论