22

Although Ubuntu 16.04 release notes mention that:

The default VIM package has been built against python3 instead of python2.

Yet after I installed vim with the following command:

sudo apt-get install vim

And checked:

vim --version

It showed:

-python
-python3

Is it a bug? How do I get vim with Python support?

27

If you want Python 3 support in vim, install the vim-nox package (sudo apt install vim-nox) see edit below.

However, if you still need Python 2 support, install the vim-nox-py2 package (sudo apt install vim-nox-py2).

Edit: vim was recently updated to fix this issue, and you should not need to install the vim-nox package anymore to get Python 3 support.

6
  • 1
    yeah i did that..but why is the vim package not supporting python? – Saprativa Bhattacharjee Apr 30 '16 at 5:43
  • Ubuntu split the Python support from the main package into two other packages: one that supports Python 2 and one that supports Python 3. After you install one of the above packages, you should be able to use vim with Python 2/3 support. – saiarcot895 Apr 30 '16 at 12:44
  • 1
    isn't it surprising that the vim package itself doesn't support any of the pythons? the release notes mention otherwise. wiki.ubuntu.com/XenialXerus/ReleaseNotes – Saprativa Bhattacharjee May 1 '16 at 7:33
  • @saiarcot895 This apparently works for me. But where did you dig this info up? Is there a Ubuntu wiki documenting how they distribute stuff? – qweruiop Jun 14 '16 at 14:25
  • 2
    Just wanted to add that after installing vim-nox-py2 I needed to run sudo update-alternatives --set vim /usr/bin/vim.nox-py2. I believe, please correct me otherwise, without this vim points to vim.tiny or some such package which doesn't have python support. – DBS Oct 14 '16 at 0:52
3

In 17.10-18.10 it is difficult to get a copy of vim with both python2 and python3 support. The PPA setup by pi-rho has such packages for previous releases, but nothing yet for 17.10 and later.

This is what I did to get pi-rho packages running:

  1. uninstall all vim packages (this will force you to uninstall "ubuntu-minimal")
  2. download the vim packages from here that end in a "~z"
  3. download the packages perl-modules-5.24,libgdbm3, and libperl5.24
  4. install them using dpkg: go to the download directory and do sudo dpkg -i libgdbm3_1.8.3-14_amd64.deb libperl5.24_5.24.1-2ubuntu1.1_amd64.deb perl-modules-5.24_5.24.1-2ubuntu1.1_all.deb vim*.deb
  5. reinstall "ubuntu-minimal": sudo apt install ubuntu-minimal
  6. lock the vim version
    • open synaptic package manager and highlight the vim packages you just installed. Go to Package->"Lock Version"
    • you may also need to "hold" the packages with sudo apt-mark hold for each of those packages (e.g. sudo apt-mark hold vim-common vim-gnome)
2

Try installing vim-gnome instead of vim.

sudo apt-get install vim-gnome

If that can help, you can install the package python-support by downloading the latest version of python-support_X.X.X_all.deb there : https://launchpad.net/ubuntu/+source/python-support Open a terminal in same folder and install with:

dpkg -i python-support_X.X.X_all.deb

See if it helps

1
1

On Ubuntu 17.10, compiling is the solution that worked for me:

Directly inspired by this gist, I did the following:

sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
sudo apt-get install checkinstall
sudo rm -rf /usr/local/share/vim /usr/bin/vim
cd /tmp && git clone https://github.com/vim/vim
cd vim/src
make distclean
cd ..
./configure --enable-multibyte --enable-perlinterp=dynamic --enable-pythoninterp=dynamic --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu --enable-cscope --enable-gui=auto --with-features=huge --with-x --enable-fontset --enable-largefile --disable-netbeans --with-compiledby="put your name here" --enable-fail-if-missing
make
sudo make install
sudo ln -s /usr/local/bin/vim /usr/bin/vim

Don't forget to adapt the ./configure parameters so you have all the other features you need.

Now you can open vim and run the command :echo has('python') to confirm you have python 2 enabled.

1

Installing vim-nox-py2 and then running

sudo update-alternatives --config vim

worked for me.

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.