下载解压:
wget
tar -zxvf Python-2.7.6.tgz
cd Python-2.7.6
安装readline模块
vim Modules/Setup.dist
找到166行,将这句前面的注释号去掉(去掉#号) readline readline.c -lreadline -ltermcap
yum install libtermcap-devel ncurses-devel libevent-devel readline-devel
编译安装
./configure
make
make install
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
#升级后,需要把yum命令改一下,不然yum不能使用
vim /usr/bin/yum
#!/usr/bin/python2.6.6
tab补全
vim /usr/local/lib/python2.7/site-packages/tab.py
#!/usr/bin/python
# python tab file
import sys
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
Python
import tab