如何安装python解释器,如何在VIM中指定Python解释器版本?

In order to write C++ in Vim with plugin, Clang_complete.

After installing, this error occurs:

Error detected while processing function 14_ClangCompleteInit..14_initClangCompletePython:

clang_complete: No python support available.

Cannot use clang library

Compile vim with python support to use libclang

But my vim supports both python and python3. +python/dyn +python3/dyn

then I check my python interpreter:

:echo has('python') # output is 0

:echo has('python3') # output is 1

So, I think the reason is my vim dynamic load python3 interpreter by default.

Can I change python interpreter? or set default dynamic load version of python?

解决方案

You probably don't want to (or at least should not) set python3 as the default python interpreter for vim, as then some (most of) your plugins will become incompatible, such as YouCompleteMe and clang_complete itself, because they do not have python3 support. Normally plugins that do support python3 let you decide if you want to use it by adding to your .vimrc

let g:syntastic_python_python_exec = 'python3'

Solution: the :echo has('python') showing 0 is actually telling you that vim is perhaps not compiled with python2. So first check the output of vim --version and you should be able to see a list of shared libraries that your compiler has built vim against. Do you see the following? (e.g. for python 2.7):

-L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7

If not (or if you see both -lpython2.x and -lpython3.x I suggest you compile vim from source, linking it specifically to -lpython2.x. It is not that difficult to build vim from source. First make sure to remove all your current vim installation, for instance using aptitude you'd do:

sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common

clone vim mercurial

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

cd vim

and then run ./configure with the following flags:

./configure --with-features=huge \

--enable-cscope \

--enable-pythoninterp \

--enable-largefile \

--with-python-config-dir=/usr/lib/python2.7/config

you might also want to link against ruby and lua if you want, and then finally run

make build

make install

Here is shell script that will automate the whole process for you. This might be a bit of an overkill, but I think this is how you should handle this to not run with compatibility issues with your future packages.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值