歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> RHEL6.5上Vim 最新版的安裝並增加對Python2.7.5的支持

RHEL6.5上Vim 最新版的安裝並增加對Python2.7.5的支持

日期:2017/2/28 14:31:45   编辑:Linux教程

git上的很多vim插件,都需要vim的高版本,而rhel6.5默認安裝的vim為7.2,要使vim支持這些插件,讓vim更高效的工作,界面看起來更漂亮,需要編譯安裝vim的最新版。

推薦閱讀:

  • Vim學習指南 http://www.linuxidc.com/Linux/2013-08/89096.htm
  • 快速學會 Vi編輯器 http://www.linuxidc.com/Linux/2013-08/88586.htm
  • 強大的Vim 編輯器 http://www.linuxidc.com/Linux/2013-07/87544.htm
  • 在CentOS 6.2上搭建Vim開發環境 http://www.linuxidc.com/Linux/2013-07/87363.htm
  • Vim 7.4a 發布,全新更快的正則表達式引擎 http://www.linuxidc.com/Linux/2013-07/87035.htm
  • CentOS 5.4 安裝高亮Vim編輯工具 http://www.linuxidc.com/Linux/2013-06/86508.htm
  • Vim技巧分享:C語言設置 http://www.linuxidc.com/Linux/2012-12/77124.htm
  • Ubuntu中設置Vim的行號 http://www.linuxidc.com/Linux/2012-12/75485.htm
  • Vim編輯器使用基礎教程 http://www.linuxidc.com/Linux/2013-05/84031.htm

1. 查看rhel6.5的python默認安裝版本
2. 安裝python多版本管理工具
3. 安裝python 2.7.5
4. vim最新版的編譯安裝
5. 使用pip安裝ipython

1. 查看rhel6.5的python默認安裝版本

rhel 6.5默認安裝的python 為 2.6.6從下面的輸出可以看到:

# python

Python 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)

2. 安裝python多版本管理工具

需要使用新版本Python的相關功能,但是又不想要影響到系統自帶的Python,這個時候就需要實現Python的多版本共存。

# curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

在.bashrc中添加

# vim .bashrc

export PYENV_ROOT="${HOME}/.pyenv"

if [ -d "${PYENV_ROOT}" ]; then

export PATH="${PYENV_ROOT}/bin:${PATH}"

eval "$(pyenv init -)"

fi

# source .bashrc


pyenv 常用命令

pyenv install --list 查看可安裝的版本

pyenv install 2.7.5 安裝指定版本

pyenv versions 查看當前已安裝的python版本

pyenv version 查看當前使用的Python版本

pyenv global 2.7.5 設置全局的python版本

pyenv local 2.7.5 設置局部python,只影響當前工作目錄


建議不要使用global切換因為當前系統有些軟件運行依賴當前系統默認版python 如yum

3. 安裝python 2.7.5

安裝依賴:

yum -y install gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel

為使pyenv安裝python 2.5.7更快,導入python國內源

# export PYTHON_BUILD_MIRROR_URL="http://pyenv.qiniudn.com/pythons/"


使用pyenv安裝python 2.5.7

[root@www ~]# pyenv install 2.7.5

Downloading Python-2.7.5.tgz...

-> http://pyenv.qiniudn.com/pythons/b4f01a1d0ba0b46b05c73b2ac909b1df

Installing Python-2.7.5...

patching file ./Modules/readline.c

Hunk #1 succeeded at 204 (offset -2 lines).

Hunk #2 succeeded at 747 (offset -2 lines).

Hunk #3 succeeded at 857 (offset -2 lines).

Hunk #4 succeeded at 905 (offset -13 lines).

Installed Python-2.7.5 to /root/.pyenv/versions/2.7.5

Downloading setuptools-3.6.tar.gz...

-> https://pypi.python.org/packages/source/s/setuptools/setuptools-3.6.tar.gz

Installing setuptools-3.6...

Installed setuptools-3.6 to /root/.pyenv/versions/2.7.5

Downloading pip-1.5.6.tar.gz...

-> https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz

Installing pip-1.5.6...

Installed pip-1.5.6 to /root/.pyenv/versions/2.7.5

可以看到使用pyenv安裝python2.7.5不但安裝了python,而且還安裝了pip 1.5.6

# pyenv versions

* system (set by /root/.pyenv/version)

2.7.5

pip的單獨安裝方法:

# wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py

# python get-pip.py

python多版本之間的切換:

# pyenv versions

* system (set by /root/.pyenv/version)

2.7.5

# pyenv local 2.7.5

# pyenv versions

system

* 2.7.5 (set by /root/.python-version)

4. vim最新版的編譯安裝

下載源碼:

# yum -y install hg

# hg clone https://code.google.com/p/vim/ vim

要使vim支持python需要安裝pythen-devel:

# yum install -y python-devel

# ./configure --with-features=huge \

--enable-gui=gnome2 --enable-luainterp=yes --enable-pythoninterp=dynamic \

--enable-rubyinterp=yes --enable-perlinterp=yes --enable-cscope \

--enable-fontset --enable-multibyte --enable-sniff --enable-xim \

--prefix=/usr/local/vim74 \

--with-python-config-dir=/root/.pyenv/versions/2.7.5/lib/python2.7/config

# make && make install

# echo 'PATH=/usr/local/vim74/bin:$PATH' > /etc/profile.d/vim.sh

#source /etc/profile

# echo $PATH

#vim /etc/man.conf

MANPATH /usr/local/vim74/share/man

# vim .vimrc 添加

set nocompatible " No to the total compatibility with the ancient vi


編譯過程中出現以下錯誤的解決:

/usr/bin/perl /usr/share/perl5/ExtUtils/xsubpp -prototypes -typemap \

/usr/share/perl5/ExtUtils/typemap if_perl.xs >> auto/if_perl.c

Can't open perl script "/usr/share/perl5/ExtUtils/xsubpp": No such file or directory

make[1]: *** [auto/if_perl.c] Error 2

make[1]: Leaving directory `/root/soft/vim/src'

make: *** [first] Error 2

解決辦法:

yum search perl | grep ExtUtils

yum install -y perl-ExtUtils-Embed

查看我們新安裝的vim:

# vim

:version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 22 2014 09:55:19)

5. 使用pip安裝ipython

# pip install ipython

Copyright © Linux教程網 All Rights Reserved