26

I'm trying to upgrade my Vim installation to version 8.0, but it doesn't support both Python and Python 3 as the below image.

(PS: Because of this problem, I cannot use the YCM (YouCompleteMe) plugin now.)

  1. I installed Vim 8.0 as in the following commands.

  2. I'm using Ubuntu 16.04 (Xenial Xerus).

How can I handle this problem?

sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim

Enter image description here

6
  • 1
    Looks like that version of Vim was compiled without Python support. Not a whole lot you can do about that. If you want to run the latest Vim version on Ubuntu then compiling it yourself is probably the easiest option. Nov 11, 2016 at 17:55
  • 2
    No python, no ruby, no perl, no clipboard… that build is very close to useless. What do you get if you install vim-gtk instead of vim?
    – romainl
    Nov 11, 2016 at 18:37
  • 1
    @Carpetsmoker How can I compile it by myself? Can you explain a little bit specific or giving me a link? Nov 12, 2016 at 3:24
  • @romainl Is there vim-gtk which supports vim 8.0? Nov 12, 2016 at 3:25
  • Yes, in that ppa.
    – romainl
    Nov 12, 2016 at 10:16

7 Answers 7

15

The pi-rho/dev PPA now supports Vim 8, and like it always has, includes support for Python/Python3:

$ vim --version | grep python
+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      +python3/dyn     +wildignore
$ apt-cache policy vim   
vim:
  Installed: 2:8.0.0134-1ubuntu1~ppa1~x
  Candidate: 2:8.0.0134-1ubuntu1~ppa1~x
  Version table:
 *** 2:8.0.0134-1ubuntu1~ppa1~x 500
        500 http://ppa.launchpad.net/pi-rho/dev/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     2:7.4.1689-3ubuntu1.2 500

Of late, the pi-rho/dev PPA hasn't had updated Vim builds. I use the jonathonf/backports PPA now:

$ vim --version | grep python
+comments          +libcall           -python            +vreplace
+conceal           +linebreak         +python3           +wildignore
$ apt-cache policy vim-gnome
vim-gnome:
  Installed: 2:8.0.1542-0york1~16.04
  Candidate: 2:8.0.1542-0york1~16.04
  Version table:
 *** 2:8.0.1542-0york1~16.04 500
        500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main amd64 Packages
        500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main i386 Packages
        100 /var/lib/dpkg/status
     2:7.4.1689-3ubuntu1.2 500
        500 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
     2:7.4.1689-3ubuntu1 500
        500 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

The PPA also contains newer versions of several other packages.

6
  • ♦ Thanks, I used vim-nox alternatively. I should try this one. Feb 9, 2017 at 1:47
  • how to install vim8 ? i added the PPA but executing sudo apt-get install vim gets me vim7 without pythin
    – weima
    Jun 22, 2017 at 10:55
  • @weima did you do an apt-get update after adding the PPA? Jul 4, 2017 at 8:49
  • 1
    jonathonf/backports no longer has vim builds Aug 2, 2018 at 1:54
  • 2
    @PengheGeng they moved it to a separate PPA (jonathonf/vim)
    – muru
    Aug 2, 2018 at 1:55
8

From your question it appears that you have installed vim-tiny 8.0 that is a very minimal Vim runtime without plugins. You can confirm this using this:

dpkg -l | grep vim

You can have several Vim runtimes, but the version running when you do vim will be the version that you can see indicated here:

update-alternatives --list vim

You can check other versions. My suggestion is that you decide between full versions with support for GUI, and you can choose between vim-gtk2/vim-gtk3 packages or vim-nox that is a full version, but without a GUI.

Now, IIRC, the Vim full version in Debian/Ubuntu doesn't come with Python 2 AND Python 3 at the same time in 7.x versions. I don't know how the case is with Vim 8, because I use neovim now. If this is the case for you and you are going to need BOTH Python engines supported by Vim 8 (this will not be your case for use YouCompleteMe; this one works with Python 2 support only) then you will need to compile from sources your own Vim 8.0.

1
  • Soils Thanks, I installed vim-nox, however I would try to compile from sources someday. Feb 9, 2017 at 1:45
6

you should use

sudo apt-get install vim-nox

instead, to get a "huge-version".

4
  • I want to use vim 8.0 or later. Is there vim.nox which supports that? Nov 12, 2016 at 3:26
  • @HyunHoYeo looks like vim-nox in Ubuntu 16.04 is vim 8.0 (you can check after install by doing vim --version and I got VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 05 2017 20:17:49)
    – james-see
    Feb 8, 2017 at 4:55
  • @jamescampbell Thanks, I upgraded my Ubuntu to 16.04 version and downloaded it. Feb 9, 2017 at 1:43
  • This works on Debian 11.
    – user42954
    Jul 29, 2022 at 18:40
6

Solution 1 :

  • Install VIM Editor(Install any one of them of vim variant) :

    • vim-gtk3 :- This package contains a version of vim compiled with a GTK3 GUI and support for scripting with Lua, Perl, Python, Ruby, and Tcl. In order to install this package :

      sudo apt install vim-gtk3   
      
    • vim-gtk :- This package contains a version of vim compiled with a GTK2 GUI and support for scripting with Lua, Perl, Python, Ruby, and Tcl. In order to install this package :

      sudo apt install vim-gtk   
      
    • vim-nox :- enhanced vi editor Like vim-tiny, vim-nox is a minimal vim installation and support for scripting with Lua, Perl, Python, Ruby, and Tcl but no GUI. It comes with mouse support, but no clipboard support, IIRC. In order to install this package :

      sudo apt install vim-nox
      
  • Set Vim as a default editor(assuming installed variant is vim-gtk3)

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

Solution 2 :

Otherwise, you can compile Vim from source code (assuming you're using Debian based system)

Prepare your system

  • Install

    sudo apt install libncurses5-dev \
    libgtk2.0-dev libatk1.0-dev \
    libcairo2-dev python-dev \
    python3-dev git
    
  • Remove Vim if you already have

    sudo apt remove vim vim-runtime gvim  
    

configure and make

cd /usr && sudo git clone https://github.com/vim/vim.git && cd vim  

sudo ./configure --with-features=huge \
--enable-multibyte \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \  # pay attention here check directory correct
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ \  # pay attention here check directory correct
--enable-gui=gtk2 \
--enable-cscope \ 
--prefix=/usr/local/

sudo make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 

Preparing deb package using checkinstall

  • And install that package

    cd /usr/vim && sudo checkinstall
    
  • Or, if want to just create a package use --install=no option with checkinstall

Set Vim as a default editor

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   

Verify that you're running the new Vim binary by looking

vim --version | grep python

References :
- Building Vim from Source
- checkinstall
- VIM variants

1
5

You should install vim from source. That way, you have control over what is included. See the following for more info and a step by step walkthrough. It is relatively easy.

https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
https://github.com/vim/vim
1
  • Please avoid posting a link-only answer since it could change in the future, leaving people with no answer to their question. At least include the essential parts from the linked page. Jan 6, 2017 at 13:27
1

Just checked, the vim-nox (v. 8.1) available from the PPA had been compiled with Python 3 (only, not both, if you really need both I would advise to switch to Neovim).

0

This is only for Windows guys who got the similar issure:

On Windows 64-bit, you MUST install the same bit python version as your VIM. etc.

32bit vim => 32bit python
64bit vim => 64bit python

Otherwise python2x.dll or python3x.dll will NOT be loaded.

2
  • OP was using a vim binary that was compiled without Python. Additionally, he's using it on Linux, not Windows.
    – Herb
    Jun 29, 2018 at 20:42
  • @HerbWolfe yes, I know. It may not be proper but I put it here just for some windows guys who hit this post for solution. I spent hours to resolve this issue and want to same others some time on it. But thank you for the reminding. Jul 17, 2018 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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