Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Python support in gVim on Windows?

Tags:

python

vim

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)
like image 766
wassimans Avatar asked Jan 17 '11 21:01

wassimans


People also ask

How do I know if vim supports python?

Run :ve[rsion] in command-line mode or run vim --version from Bash. If vim was compiled with Python 3, you'll find -python and +python3 . If vim was compiled with Python 2, you'll find +python and -python3 . If vim was compiled without Python support, you'll find -python and -python3 1.

What Gvim Windows?

vim is a Linux based tool where it is also cloned into other platforms like Windows, MacOS, BSD, etc. vim is a console, command-line based tool which is used with some keyboard shortcuts. Gvim is the graphical version of the vim which supports all vim features and adds extra GUI for vim usage.


2 Answers

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
-DFEAT_CSCOPE -DFEAT_ NETBEANS_INTG -DFEAT_XPM_W32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjGOLYHTR/ / Ox /GL -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMI C_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl83.dll\" -DDYNAM IC_TCL_VER=\"8.3\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -D FEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python31.dll\" -DFEAT_PERL -DDYNAMI C_PERL -DDYNAMIC_PERL_DLL=\"perl512.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 1 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby191.dll\" -DFEAT_BIG /Fd.\ObjGOLYHTR/ /Zi

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.

like image 190
Daniel Avatar answered Sep 20 '22 09:09

Daniel


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") 
like image 23
David Avatar answered Sep 18 '22 09:09

David