1

I recently updated my vim to have Python3 support. I was having trouble with it, but I eventually solved the problem that I described here. Now I am trying to make a vim plugin using python3 and I wrote a test file but when I try to do source % I get:

Error detected while processing /home/marv/Documents/vimPlugins/test/plugin/test.vim:
line    4:
E319: Sorry, the command is not available in this version: python import sys
line    5:
E319: Sorry, the command is not available in this version: python import vim
line    6:
E319: Sorry, the command is not available in this version: python sys.path.append(vim.eval('expand("<sfile>:h"
)'))

Here is all my code. FILE: test.vim

" --------------------------------
  " Add our plugin to the path
  " --------------------------------
  python import sys
  python import vim
  python sys.path.append(vim.eval('expand("<sfile>:h")'))

  " --------------------------------
  "  Function(s)
  " --------------------------------
  function! TemplateExample()
  python << endOfPython

  from test import test_example

  for n in range(5):
      print(test_example())

  endOfPython
  endfunction

  " --------------------------------
  "  Expose our commands to the user
  " --------------------------------
  command! Example call TemplateExample()       

FILE: test.py

def test_example():
    return "Happy Hacking!"

again I have python3 working on this in vim doing echo has ('python3') returns a 1.

Here is part of the output for version

Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +dialog_con_gui  +job             +mouse_sgr       +rightleft       +user_commands
+arabic          +diff            +jumplist        -mouse_sysmouse  +ruby            +vertsplit
+autocmd         +digraphs        +keymap          +mouse_urxvt     +scrollbind      +virtualedit
+balloon_eval    +dnd             +lambda          +mouse_xterm     +signs           +visual
+browse          -ebcdic          +langmap         +multi_byte      +smartindent     +visualextra
++builtin_terms  +emacs_tags      +libcall         +multi_lang      +startuptime     +viminfo
+byte_offset     +eval            +linebreak       -mzscheme        +statusline      +vreplace
+channel         +ex_extra        +lispindent      +netbeans_intg   -sun_workshop    +wildignore
+cindent         +extra_search    +listcmds        +num64           +syntax          +wildmenu
+clientserver    +farsi           +localmap        +packages        +tag_binary      +windows
+clipboard       +file_in_path    +lua             +path_extra      +tag_old_static  +writebackup
+cmdline_compl   +find_in_path    +menu            +perl            -tag_any_white   +X11
+cmdline_hist    +float           +mksession       +persistent_undo -tcl             -xfontset
+cmdline_info    +folding         +modify_fname    +postscript      +termguicolors   +xim
+comments        -footer          +mouse           +printer         +terminfo        +xpm
+conceal         +fork()          +mouseshape      +profile         +termresponse    +xsmp_interact
+cryptv          +gettext         +mouse_dec       -python          +textobjects     +xterm_clipboard
+cscope          -hangul_input    +mouse_gpm       +python3         +timers          -xterm_save
+cursorbind      +iconv           -mouse_jsbterm   +quickfix        +title
+cursorshape     +insert_expand   +mouse_netterm   +reltime         +toolbar

anyone know why I get this error of "the command is not available in this version:"?

  • 1
    You get that error because the :python command actually isn't available in your Vim. Please read: :h python3. – Sato Katsura Sep 21 '16 at 6:03
1
  • Use :python foo if you have +python and/or +python/dyn.
  • Use :python3 foo if you have +python3 and/or +python/dyn.

Since you only have +python3 there's no reason whatsoever to expect :python to work.

See :help python.

  • I don't understand, please explain I am a total noob. I don't want to use python I want to use python3. How and where am I trying to use python and not python3? – user1314272 Sep 21 '16 at 9:07
  • facepalm sorry I see my obvious error – user1314272 Sep 21 '16 at 9:17

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.