Build Vim With Python3 Support

I’m on an older version of a Debian based os that only has vim 8.2 available. But I wanted to use YouCompleteMe so I built vim from source. Here are the brief steps I followed.

Install Packages

Note: This assumes that build essential is installed.

sudo apt install libncurses-dev python3-dev

Follow the Build directions on the vim site

git clone https://github.com/vim/vim.git
cd vim

Configure to enable python3 support

./configure --with-features=huge \
            --enable-multibyte \
            --enable-python3interp \
            --prefix=/usr/local

Build

cd src
make

Verify

./vim --version
...
+python3
...

Install

sudo make install

Update Alternatives

sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim