VIM python support on Ubuntu 16.04

20,530

Solution 1

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>

Solution 2

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

Solution 3

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 [email protected]
Compiled by [email protected]
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
Share:
20,530

Related videos on Youtube

Max
Author by

Max

Updated on September 18, 2022

Comments

  • Max
    Max over 1 year

    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?

  • muru
    muru almost 8 years
    python 4? O.o
  • the_velour_fog
    the_velour_fog almost 8 years
    @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.
  • muru
    muru almost 8 years
    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.
  • Dennis Williamson
    Dennis Williamson over 7 years
    If you don't uninstall the other package, you can switch between Python 2 and 3 support using sudo update-alternatives --config vim
  • Fergal Moran
    Fergal Moran over 7 years
    @DennisWilliamson - this should be the accepted answer.
  • krumpelstiltskin
    krumpelstiltskin over 6 years
    The pi-rho's PPA has no Artful version of vim. Does anyone have another solution?
  • krumpelstiltskin
    krumpelstiltskin over 6 years
    For Artful 17.10 I added instructions here: askubuntu.com/a/982986/14747