標籤:python.linux.安裝
聲明,普通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
python安裝及其tab補全