First, install the Readline-devel package
Python's compiled installation relies on this package
Yum-y Install Readline-devel
Second, installation Python2.7.12
Python official website (download here):https://www.python.org/
# Tar XF python-2.7.12.tgz
# CD Python-2.7.12
#./configure--prefix=/usr/local/python27
# Make && make install
# ln-sv/usr/local/python27/bin/python2.7/usr/bin/python27
third, add Python auto complement function for VIM editor
1 , download Python auto-complete plugin: pydiction
wget https://github.com/rkulla/pydiction/archive/master.zip
# Unzip-q Master
# MV Pydiction-master Pydiction
# mkdir-p ~/.vim/tools/pydiction
# cp-r Pydiction/after ~/.vim
# CP Pydiction/complete-dict ~/.vim/tools/pydiction
2, ~/.VIM directory structure is as follows:
# Tree ~/.vim
/root/.vim
├──after
│└──ftplugin
│└──python_pydiction.vim
└──tools
└──pydiction
└──complete-dict
3, edit ~/.VIMRC, add the following content
FileType plugin on
Let g:pydiction_location = ' ~/.vim/tools/pydiction/complete-dict '
4, use Vim to edit a py file, test whether successful
The scenario description is configured successfully
Iv. Configuring automatic completion for Python in interactive mode
1./usr/local/python27/lib/python2.7/site-packages add tab.py file in Python installation directory
The tab file contents are as follows:
#!/usr/bin/env python27#python startup fileImportSYSImportReadLineImportRlcompleterImportatexitImportOS#Tab CompletionReadline.parse_and_bind ('Tab:complete')#History FileHistfile = Os.path.join (os.environ['HOME'],'. Pythonhistory')Try: Readline.read_history_file (histfile)exceptIOError:PassAtexit.register (Readline.write_history_file, Histfile)delOS, Histfile, ReadLine, Rlcompleter
2. Add Environment variables:
#vim ~/.BASHRC Add the following:
#for python tab
Export pythonstartup=/usr/local/python27/lib/python2.7/site-packages/tab.py
3. Re-login to the shell for testing:
and shell usage, press TAB to complete, press the TAB key to list all the commands that begin with the input character.
Python2.7.12 Development Environment Construction (auto-complete)