How to solve "requires python 2.x support" in linux vim,and it have python 2.6.6 in my system

25,373

Solution 1

In Ubuntu/Lubuntu 16.04, I have success with installing vim-gnome-py2

sudo apt-get install vim-gnome-py2

My vim --version | grep python after installing it:

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

You may need to remove other packages such as vim-gnome, vim-gtk, vim-nox ... to avoid conflicts.

Solution 2

With Debian 8, installing vim-nox helped me.

apt-get install vim-nox

Solution 3

Neovim? Anyone?

Getting set up with neovim and ycm

Installation

On arch, for example, yaourt -S python-neovim

Basically, you need python support.

Setting up 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** :)

Using vundle to manage YCM:

Hopefully, you are still inside you ~/.config/nvim/init.vim ... add these lines in order to add Vundle and You Complete Me (YCM) plugins:

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

NOTE
All of the above lines are required (with the exception of Plugin 'vundleVim/Vundle.vim' as that just tells vundle to manage itself for updates).

Now run these commands inside nvim/vim to (1) source the current file and (2) install all the plugins with vundle.

:so %
:PluginInstall

Last step: compiling YCM

We need one last step for YCM. (Usually, you do not need to do this with Plugins as they will use vimL or something. However, YCM needs something a bit faster, so we need to do a little something more.)

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

All done!
:)

Getting set up in vim instead

meh

If you insist, simply put all of vundle's things inside ~/.vim/bundle/ and then use

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

inside your ~/.vimrc. Note the difference in the set rtp+= AND the call vundle#begin ... in vim and nvim, they point to different directories.

Solution 4

It looks like you didn't install vim with Python support.

You can check this by running vim --version.

If you see a -python string in the output, that means you didn't install it with Python support. +python means it's installed with Python support.

To resolve this, either find a package in your package manager that installs it with Python support (see other answers) or download the source code and compile it with Python support. (Run the configure script with --enable-pythoninterp=yes. If you want Python 3 support to be enabled, use --enable-python3interp=yes)

Solution 5

I solved the issue installing vim-gnome-py2 that has python2 interpreter support

sudo apt-get install vim-gnome-py2

and making it the default alternative using update-alternatives

sudo update-alternatives --set vim /usr/bin/vim.gnome-py2

Installing vim-gnome-py2 could not be enough

Share:
25,373
Firemky
Author by

Firemky

Updated on July 24, 2022

Comments

  • Firemky
    Firemky almost 2 years
    [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
    

    i have try it in centos 6.4 ,and fedora 20. It's the same problem. i am new coder ,i really do not know why it happen.

  • Hilton Shumway
    Hilton Shumway about 8 years
    As @neoben pointed out, running sudo update-alternatives --set vim /usr/bin/vim.gnome-py2 works in place of removing other conflicting packages
  • dylnmc
    dylnmc almost 8 years
    Actually - just a small update - neovim is still under heavy development and sometimes you get a seg-fault. Vim's config directory is ~/.vim or ~/.config/vim and you can do the same thing in those. :)