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 �Cy 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.


你可能感兴趣的:(linux,python,安装)