Welcome 微信登录

首页 / 操作系统 / Linux / RHEL6.5上Vim 最新版的安装并增加对Python2.7.5的支持

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安装ipython1. 查看rhel6.5的python默认安装版本rhel 6.5默认安装的python 为 2.6.6从下面的输出可以看到:# pythonPython 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 .bashrcexport 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  如yum3. 安装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.5Downloading Python-2.7.5.tgz...-> http://pyenv.qiniudn.com/pythons/b4f01a1d0ba0b46b05c73b2ac909b1dfInstalling Python-2.7.5...patching file ./Modules/readline.cHunk #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.gzInstalling 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.gzInstalling 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.5pip的单独安装方法:# 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.confMANPATH /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.cCan"t open perl script "/usr/share/perl5/ExtUtils/xsubpp": No such file or directorymake[1]: *** [auto/if_perl.c] Error 2make[1]: Leaving directory `/root/soft/vim/src"make: *** [first] Error 2解决办法:yum search perl | grep ExtUtilsyum install -y perl-ExtUtils-Embed查看我们新安装的vim:# vim:versionVIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 22 2014 09:55:19)5. 使用pip安装ipython# pip install ipython本文永久更新链接地址