I have Ubuntu 14.04 installed and Vim in its repos is compiled without Python 3 support. Because of that, python-mode plugin can't work with Python 3 code. What's the easiest way to get Vim with Python 3 support?

1 Answer 1


It seems on Debian-based systems (at least) you can't have your cake and eat it too. It's either Python 2 or Python 3. Due to how the Python libraries are built, you can only use one variant within a Vim session. You can build with both, but if Python 2 is called in Vim, then Python 3 cannot be called in the same session, and vice versa. On Arch Linux as well, Vim is only compiled with one of Python 2 (vim, gvim) or Python 3 (vim-python3, gvim-python3).

Before 16.04

To rebuild the Vim that the repositories provide:

sudo apt-get build-dep vim
apt-get source vim
cd vim-*  # it will be vim-7.4.something

Edit debian/rules and replace:

ALLINTERPFLAGS+=--enable-pythoninterp --with-python-config-dir=$(shell python-config --configdir)


ALLINTERPFLAGS+=--enable-pythoninterp=dynamic --with-python-config-dir=$(shell python-config --configdir)
ALLINTERPFLAGS+=--enable-python3interp=dynamic --with-python3-config-dir=$(shell python3-config --configdir)

Then run:

dpkg-buildpackage -us -uc

Have lunch. (Or tea if you used -j $(nproc).)

Now, multiple .deb files will have been created in the parent directory. To see which:

cd ..
ls vim*.deb

Along with the particular variant you want to install (vim, vim-gnome, vim-gtk, etc.), you'll have to install vim-common_*.deb, vim-runtime_*.deb, and for the GUI versions, vim-gui-common_*.deb. For example, with vim-gnome, and the current version of vim in the repositories:

sudo dpkg -i vim-gnome_7.4.052-1ubuntu3_amd64.deb vim-common_7.4.052-1ubuntu3_amd64.deb vim-gui-common_7.4.052-1ubuntu3_all.deb vim-runtime_7.4.052-1ubuntu3_all.deb


$ vim --version | grep python
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace

The pi-rho/dev PPA builds Vim in this fashion, so you can use the PPA instead of manually building it.


As of 16.04, Ubuntu builds Vim with Python 3 support. Python 2 support is provided by the -py2 packages (vim-nox-py2, vim-gnome-py2, etc.).


  • Vim compiled this way gives me an error when trying to load pymode functions: This Vim cannot execute :py3 after using :python. When I was using Gentoo instead of Ubuntu, vim used python 3 and this problem did not exist.
    – CrabMan
    Feb 16, 2015 at 19:54
  • @CrabMan Read the first paragraph.
    – muru
    Feb 16, 2015 at 19:54
  • @CrabMan What you can try is to build only with Python3 (essentially swapping python3 and python in the lines that already existed). Then anything that tried to load python2 will fail.
    – muru
    Feb 16, 2015 at 19:57
  • YouCompleteMe unavailable: requires Vim compiled with Python 2.x support. I think it's one of the most important vim extensions I use so that's not an option.
    – CrabMan
    Feb 16, 2015 at 19:58
  • Also as far as I understand I can just include "py3 3" line in my .vimrc and it will have the same effect as compiling vim with just python3 support.
    – CrabMan
    Feb 16, 2015 at 20:01

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