How to enable Python support in gVim on Windows?


I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?

I'm using:

  • Windows XP SP3
  • gVim v. 7.3
  • Python 2.7.13 (ActivePython through Windows Installer binaries)
8/18/2013 7:26:31 PM

Accepted Answer

Usually, python support is built in the official gvim distribution.

You will need to install python though: Python Downloads

to check if vim supports python:

:echo has("python")
3/1/2017 9:03:08 AM

I had the same issue, but on Windows 7, and a restart didn't fix it.

I already had gVim 7.3 installed. At the time of writing the current Python version was 3.3, so I installed that. But :has ("python") and :has ("python3") still returned 0.

After much trial and error, I determined that:

  • If gVim is 32-bit, and it usually is even on 64-bit Windows (you can confirm using the :version command), then you need the 32-bit python installation as well
  • No restart of Windows 7 is required
  • The version of python needs to match the version that gVim is compiled for as it looks for a specific DLL name. You can work this out from the :version command in gVim, which gives something like:

Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32

So the above told me that I don't actually want python 3.3, I need 3.1 (or 2.7). After installing python 3.1, :has ("python") still returns 0, but :has ("python3") now returns 1. That should mean that python based scripts will now work!

I imagine future versions of gVim may be compiled against other versions of python, but using this method should let you work out which version is required.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow