git上的很多vim插件,都需要vim的高版本,而rhel6.5默认安装的vim为7.2,要使vim支持这些插件,让vim更高效的工作,界面看起来更漂亮,需要编译安装vim的最新版。
推荐阅读:
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...
->
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