python安装readline模块
yum安装readline、readline-devel
#yum install -y readline-devel
下载安装setuptools
#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e --no-check-certificate
#tar -zxvf setuptools-0.6c11.tar.gz
#cd setuptools-0.6c11
#python setup.py install
下载安装readline
#wget https://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz#md5=578237939c81fdbc2c8334d168b17907 --no-check-certificate
#tar -zxvf readline-6.2.4.1.tar.gz
#cd readline-6.2.4.1
#python setup.py install
# python
Python 2.7.5 (default, Sep 27 2014, 17:30:23)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline, rlcompleter; readline.parse_and_bind("tab: complete")
这样就把python自动补全的功能安装完毕
如果想启动python编辑器就自动加载,则需要做以下操作
切换到python目录,我的系统是/usr/lib/python2.7
编辑startup.py脚本
#!/usr/bin/python import readline, rlcompleter readline.parse_and_bind("tab: complete")
授权
#chmod 755 /usr/lib/python2.7/startup.py
修改根目录的.bashrc文件
添加如下一行
export PYTHONSTARTUP=/usr/lib/python2.7/startup.py
重新加载环境变量
#source .bashrc
这样再进入python编辑器就可以自动补全啦
来源:oschina
链接:https://my.oschina.net/u/4518095/blog/4744438