如何在linux vim中解决“需要python 2.x支持”,并且在我的系统中有python 2.6.6

时间:2013-11-23 09:54:57

标签: python linux vim

[root@localhost bin]# python -V
Python 2.6.6
[root@localhost bin]# ./vim
UltiSnips requires py >= 2.6 or any py3
YouCompleteMe unavailable: requires Vim compiled with  Python 2.x support

我在centos 6.4和fedora 20中尝试过它。这是同样的问题。 我是新编码员,我真的不知道为什么会这样。

13 个答案:

答案 0 :(得分:17)

使用Debian 8,安装vim-nox帮助了我。

apt-get install vim-nox

答案 1 :(得分:17)

在Ubuntu / Lubuntu 16.04中,我成功安装vim-gnome-py2

sudo apt-get install vim-gnome-py2

安装后我的vim --version | grep python

$ vim --version | grep python
+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore

您可能需要删除其他软件包,例如vim-gnomevim-gtkvim-nox ...以避免冲突。

答案 2 :(得分:11)

Neovim?任何人吗?

使用neovim和ycm进行设置

安装

在拱门上,例如yaourt -S python-neovim

基本上,你需要python支持。

设置neovim

mkdir -p ~/.config/nvim/bundle/Vundle.vim/
cp ~/.vimrc ./init.vim
git clone https://github.com/VundleVim/Vundle.vim.git
git clone 
nvim ~/.config/nvim/init.vim # edit nvim init file (using nvim, **of course** :)

使用vundle管理YCM:

希望你仍然在你身边~/.config/nvim/init.vim ...添加这些行以添加VundleYou Complete Me (YCM)插件:

set nocompatible
filetype off
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin('~/.config/nvim/bundle')
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
call vundle#end()
filetype plugin indent on

注意
以上所有行都是必需Plugin 'vundleVim/Vundle.vim'除外,因为它只是告诉vundle管理自己的更新)。

现在在nvim / vim 中运行这些命令以(1)获取当前文件,以及(2)使用vundle安装所有插件。

:so %
:PluginInstall

最后一步:编译YCM

我们需要YCM的最后一步。 (通常,你不需要使用插件,因为他们会使用vimL或者其他东西。但是,YCM需要更快的东西,所以我们需要做更多的事情。)

cd ~/.config/nvim/bundle/YouCompleteMe/
python2 install.py

全部完成!
:)

在vim中设置

MEH

如果你坚持,只需将所有vundle的内容放在~/.vim/bundle/内,然后再使用

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin('~/.vim/bundle')
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe' " if on arch, I recommend installing vim-youcompleteme-git
call vundle#end()
filetype plugin indent on
你的〜/ .vimrc里面。 注意 {vid和nvim中的set rtp+=call vundle#begin ...的差异,它们指向不同的目录。

答案 3 :(得分:8)

看起来你没有安装带有Python支持的vim。

您可以通过运行vim --version来查看此内容。

如果在输出中看到-python字符串,则表示您没有使用Python支持安装它。 +python表示它已安装Python支持。

要解决此问题,请在程序包管理器中找到一个包,该程序包使用Python支持安装它(请参阅其他答案)或下载源代码并使用Python支持进行编译。 (使用configure运行--enable-pythoninterp=yes脚本。如果要启用Python 3支持,请使用--enable-python3interp=yes

答案 4 :(得分:5)

我解决了安装具有python2解释器支持的 vim-gnome-py2 的问题

sudo apt-get install vim-gnome-py2

并使用 update-alternatives

将其作为默认替代方案
sudo update-alternatives --set vim /usr/bin/vim.gnome-py2

安装vim-gnome-py2还不够

答案 5 :(得分:3)

在Ubuntu 16.04中,我采取了以下步骤:

  1. cd ~/.vim/bundle
  2. rm -rf YouCompleteMe/
  3. vim +PluginInstall +qall
  4. cd ~/.vim/bundle/YouCompleteMe
  5. ./install.sh --clang-completer
  6. 此后没有问题。

答案 6 :(得分:1)

消息中解释了什么:你的vim不是用python支持构建的。解决方案也很明显:使用python支持安装vim。

使用您的软件包管理器安装我认为“vim-enhanced”的最大版本。希望您的包管理器能够处理依赖关系。

答案 7 :(得分:0)

这意味着在编译vim时不包括python支持。

检查您的发行版是否有像vim-with-full-features这样的包(我听说CentOS中没有),或者自己构建它。快乐的vimming。

答案 8 :(得分:0)

我认为这是因为您需要安装python-dev。他解决了我的问题。

$ sudo apt-get install python-dev

答案 9 :(得分:0)

不要./configure python(2)和python3解释器:

在Ubuntu 16.04上从源代码安装vim时通过:

./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr

enable-pythoninterpenable-python3interp一起使用会导致+python/dyn+python3/dyn作为功能,这似乎会造成麻烦。如果您运行vim --version,则会在“包含的功能(+)”中看到此内容。

不要同时配置。即只使用一个python(或其他),事情就会开始正常运行。

这里看起来已经回答了(有更多信息): https://stackoverflow.com/a/23656675/1442914

答案 10 :(得分:0)

在Ubuntu 16.04上,由于同时启用了Python2和Python3,Python支持无效。

我只通过启用Python3来解决问题。当我同时启用Python2和Python3时,在vim中运行“echo has(python)|| has('python3')”,但输出0.取消启用python后,“echo has(python3)”输出1,“echo has( python)“输出0。

答案 11 :(得分:0)

以下对我有用:
注意:我正在用Python 2编译vim; Python 3出于一些奇怪的原因给了我一些问题。

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

sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev   

" Optional: so vim can be uninstalled again via dpkg -r vim  
sudo apt-get install checkinstall   

sudo rm -rf /usr/local/share/vim /usr/bin/vim  

cd ~  
git clone https://github.com/vim/vim   
cd vim  
git pull && git fetch  

" In case Vim was already installed  

cd src  
make distclean  
cd .. 

./configure \  
--enable-multibyte \  
--enable-perlinterp=dynamic \  
--enable-rubyinterp=dynamic \  
--with-ruby-command=/usr/local/bin/ruby \  
--enable-pythoninterp=dynamic \  
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \    
--enable-luainterp \  
--with-luajit \  
--enable-cscope \  
--enable-gui=auto \  
--with-features=huge \  
--with-x \  
--enable-fontset \  
--enable-largefile \  
--disable-netbeans \  
--with-compiledby="yourname" \  
--enable-fail-if-missing  

make && sudo make install  

````

答案 12 :(得分:0)

就我而言,已接受的答案here解决了该问题。执行配置脚本时,应忽略不推荐使用的参数--with-python-config-dir=