python安装及其tab补全
声明,普通linux系统都是自带python,若是2.7的版本,就用着吧,若不是建议先卸载再安装.
1.下载安装包
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
2.解压安装
tar -zxvf Python-2.7.9.tgz
cd Python-2.7.9
yum –y install readline-devel (上下左右功能)
./configure
make &&make install
3.Tab补全功能
3.1查看python路径
python
>>>import sys
>>>sys.path
[‘‘, ‘/usr/local/lib/python27.zip‘, ‘/usr/local/lib/python2.7‘, ‘/usr/local/lib/python2.7/plat-linux2‘, ‘/usr/local/lib/python2.7/lib-tk‘, ‘/usr/local/lib/python2.7/lib-old‘, ‘/usr/local/lib/python2.7/lib-dynload‘, ‘/usr/local/lib/python2.7/site-packages‘]
>>>
cd /usr/local/lib/python2.7
-------------------py附件无法上传,直接把内容复制进去
vim tab.py
#!/usr/bin/python
# python startup 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
------------------------------------------------------------------
echo export PYTHONSTARTUP=/usr/local/lib/python2.7/tab.py>>/root/.bashrc
source /root/.bashrc
至此OK.
本文出自 “君子不器” 博客,请务必保留此出处http://cesar.blog.51cto.com/4356026/1631309
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。