7

I installed debian strech two days ago. I installed vim and configured some plugins. I always encountered the following error while opening any file:

vim app.py
Error detected while processing /home/sathish/.vim/plugged/sbt-vim/plugin/sbt.vim:
line   20:
E319: Sorry, the command is not available in this version: pyfile /home/sathish/.vim/plugged/sbt-vim/plugin/../python/sbt-vim.py
Press ENTER or type command to continue

The vim version output is

vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 23 2017 12:10:29)
Included patches: 1-197, 322, 377-378, 550
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     +tcl
+balloon_eval    +folding         +mouse_xterm     +termguicolors
+browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
+clientserver    +insert_expand   +packages        +toolbar
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        +perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  +lua             +rightleft       +writebackup
+diff            +menu            +ruby            +X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     +xpm
+emacs_tags      +mouseshape      +startuptime     +xsmp_interact
+eval            +mouse_dec       +statusline      +xterm_clipboard
+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          
+farsi           +mouse_netterm   +tag_binary      
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-RY6vK3/vim-8.0.0197=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm

I added vim with python support from repository here but the error still occurs.

12

It looks like I'm a bit late, but I'll leave this here for future visitors also struggling with this.

$ sudo apt install vim-nox

This is the Vim package in Debian Stretch that adds support for scripting languages.

You should try to do it this way, as it is easier to update/remove.

Edit: Consider switching to Neovim

  • I try this already but it wont works for debian strech – Sathish Kumar Jul 5 '17 at 5:22
  • You have to completely remove previous vim installations, including related packages (xxd is an example of that), then install the clean version. – Baruch Spinoza Jul 5 '17 at 14:56
  • I just read the question again, and I realized that the issue is not about python support in general; it seems like you specifically need python 2, is that correct? – Baruch Spinoza Jul 5 '17 at 14:59
  • Yes @Baruch Its need python 2 – Sathish Kumar Jul 6 '17 at 17:42
  • vim-nox is available in stretch, buster and testing, unstable. and it has support for Python3. – Abdullah Aug 4 at 5:23
5

I too struck this issue after updating from Jessie to Stretch.

As noted in another answer, installing vim-nox should resolve this issue (as vim-nox in Stretch is compiled against python2). However, I figured that python3 is the way of the future. So I decided to fix it another way.

If you need Python2 support, installing vim-nox is probably the best method. Note that if you still have vim installed, that will continue to be the default "vim" on your system. If you wish to make vim-nox default you need to do one of the following:

  • completely remove vim; or
  • use update-alternatives to set vim-nox as default "vim"; or
  • just explicitly launch vim-nox, i.e.: vim.nox <filename>.

I fixed mine by tweaking my existing .vim plugin files. All that needs changing is swap out pyfile command for py3file:

for file in /home/user/.vim/bundle/custom/plugin/*.vim; do
    sed -i "s|pyfile|py3file|" $file
done

(obviously my username is user!:)

That solved most of the issues, but one of my .py plugins then starting giving some different (python3) errors:

Error detected while processing /home/user/.vim/bundle/custom/plugin/rst.vim:
line    2:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/.vim/bundle/custom/plugin/rst.py", line 100
    vim.command("let b:nestings = " + `self.nestings`)
                                      ^
SyntaxError: invalid syntax

So I used the 2to3 python tool to update that particular script to python3:

2to3 -w /home/user/.vim/bundle/custom/plugin/rst.py

All fixed! :)

3

I usually use this procedure for installation (used also under Debian 9)

# Clean from standard vim
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
# Vim dependency
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev libperl-dev libncurses5-dev ruby-dev

# if you want gVim add also this 
sudo apt-get install libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev

# Clean and prepare folders
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim
sudo mkdir /usr/include/lua5.1/include

# Download it and compile
cd /usr/local/src/
git clone https://github.com/vim/vim
cd vim/src
make distclean

./configure --with-features=huge \
            --enable-rubyinterp \
            --with-ruby-command=$(which ruby) \
            --enable-largefile \
            --disable-netbeans \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-perlinterp \
            --enable-luainterp \
            --with-luajit \
            --enable-gui=auto \
            --enable-fail-if-missing \
            --with-lua-prefix=/usr/include/lua5.1 \
            --enable-cscope

make
sudo make install

For Python 3.5 replace python-dev with python3-dev in the sudo apt-get install line and in the ./configure statement replace the 2.7 row and the row above with the following:

--enable-python3interp=yes \    
--with-python3-config-dir=/usr/lib/python3.5/config \

For the Python config directories, you could also use the output of python-config or python3-config:

--with-python-config-dir=$(python-config --configdir) \
# or
--with-python3-config-dir=$(python3-config --configdir) \
1

In Stretch, the packages changed from supporting Python2 to Python3. As mentioned in another answer, it's not possible to build Vim against both Python2 and Python3 in Debian.

I would suggest getting the plugin to support Python3, but if that's not possible then you would need to either build your own Vim against Python2 or use Neovim (which isn't compiled against Python, so is able to use either version).

1

I tried many possible ways of adding repositories with python support for debian stretch but none of them worked out.

Finally I build my own and then it solved my issue. Here is the link for Vim with python 2 and python support

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.