14

This question already has an answer here:

I use ubuntu 16.04. My Vim doesn't have Python support. The thing is that I installed vim, vim-gnome, vim-nox, I surfed net for hours and tried to build vim from source, I deleted some stuff like vim-tiny and ubuntu-minimal, whatever I did - nothing worked.

Can anyone help me to get that Python support for Vim?

marked as duplicate by edwinksl, Kevin Bowen, Eric Carvalho, αғsнιη, waltinator Sep 13 '16 at 2:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9

Here's what I do to get python support in vim

apt-get install -y python-software-properties software-properties-common

add-apt-repository ppa:pi-rho/dev

# add this repo so that vim has python 4? compiled in to support plugins like gundo
add-apt-repository -y ppa:pi-rho/dev
apt-get update

install vim-gtk

this install a massive vim build that will give you everything

apt-get install -y vim-gtk

Running these commands on Ubuntu 16.04 worked for me about 2 weeks ago.

problems with versions

The way this can cause problems is that by default, apt-get will install the newest version of the package, usually the pi-rho repo version is far newer than say 14.04's vim-gtk package and apt will install the pi-rho version. However on 16.04 the ubuntu universe? repo for vim-gtk has been neck and neck for versions with pi-rho - but the ubuntu package doesn't seem to have python support. ( I may be wrong on this though ). so ideally you would run

apt-cache policy vim-gtk

prior to install to check that apt will install pi-rho, if not you will have to run something like

sudo apt-get install vim-gtk=<version>
  • python 4? O.o – muru May 20 '16 at 8:39
  • @muru I'm not sure what version of python ubuntu's vim-gtk is missing. I just know when I use ubuntu's vim-gtk, gundo plugin doesn't work and gives an error about missing python..... I install vim-gtk from pi-rho repo and problem goes away. Im not sure if its the fact I run python-software-properties software-properties-common or the pi-rho version. but the commands I listed work for me. – the_velour_fog May 20 '16 at 8:43
  • Ubuntu's vim-* supports Python 2 until 16.04, and Python 3 from 16.04 onwards. pi-rho's PPA has dynamic Python2/Python3 support, so whichever is called first is enabled. It's a weird thing.. I suspect your case would be handled by the -py2 packages as well. – muru May 20 '16 at 8:45
  • The pi-rho's PPA has no Artful version of vim. Does anyone have another solution? – krumpelstiltskin Dec 3 '17 at 15:29
  • For Artful 17.10 I added instructions here: askubuntu.com/a/982986/14747 – krumpelstiltskin Dec 4 '17 at 8:59
8

Those packages have +python3 support. If you want Python 2 support (+python), install the py2 packages (vim-nox-py2, vim-gnome-py2, etc.).

  • 6
    If you don't uninstall the other package, you can switch between Python 2 and 3 support using sudo update-alternatives --config vim – Dennis Williamson Aug 8 '16 at 18:21
  • 4
    @DennisWilliamson - this should be the accepted answer. – Fergal Moran Sep 2 '16 at 20:03
6

If you get vim-nox, you'll have python 3 support:

sudo apt-get install vim-nox

Then:

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 08 2016 11:38:28)
Included patches: 1-1689
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
-balloon_eval    +float           +mouse_urxvt     +tcl
-browse          +folding         +mouse_xterm     +terminfo
++builtin_terms  -footer          +multi_byte      +termresponse
+byte_offset     +fork()          +multi_lang      +textobjects
+channel         +gettext         -mzscheme        +timers
+cindent         -hangul_input    +netbeans_intg   +title
-clientserver    +iconv           +packages        -toolbar
-clipboard       +insert_expand   +path_extra      +user_commands
+cmdline_compl   +job             +perl            +vertsplit
+cmdline_hist    +jumplist        +persistent_undo +virtualedit
+cmdline_info    +keymap          +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      +lua             +rightleft       +writebackup
+diff            +menu            +ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xsmp
+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard
+eval            +mouse_dec       +statusline      -xterm_save
+ex_extra        +mouse_gpm       -sun_workshop    -xpm
+extra_search    -mouse_jsbterm   +syntax`

If you need python 2 support instead of python 3:

sudo apt-get install vim-nox-py2

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