How to install gvim.exe on Windows with Python support?

1

2

Problem description:

For all the executable installers for Vim that are listed below, the tags +python/dyn and +python3/dyn are unanimous when installed. However, for all my local installations using these installers, none worked. I don't have enough reputation to include more than two URLs. So, reference to the installers goes to the comment.

  1. The plain Vim version from Vim Cream.
  2. The "official", yet obsolete Vim installer.
  3. "Home built" Vim distributions released by kindhearted individuals.

What has caused the problem

There is a single line of command in my _vimrc:

  let $PYTHONHOME = 'C:/Program Files/Anacoda'

While, as I played with those Vim distributions + Python packages, I did not pay attention to this :( Now, deleting this funky line cures all my problems. Nevertheless, it is good to know there are numerous ways to properly install Vim onto Windows machine.

The specific error

When I try the command python import sys, it gives me the error message "E887: Sorry, this command is disabled, the Python's site module could not be loaded." This error message would also occur when I try to invoke VOom and Vim-Latex-Suite, two Vim-plugins.

My installation attempts:

I adhere to the following two guidelines/restrictions:

  • Restriction 1: The version of Python

    According to the following discussions, it is clear that Vim may only work with Python 2.7.9 on Windows. Also, we shall match the 32-bit Vim with a 32-bit Python.

  • Restriction 2: The order of installation

    The gvim.exe shall need to see the python27.dll and the python33.dll. (This is accessible through :version in Vim.) So, one needs to install the Python distributions first, and then install the Vim executables. Yet, it is unclear to me if two versions of Python may exist on one Windows machine in harmony. So, I have never had the python33.dll available on my machine. Yet, gvim.exe may only complain about python27.dll should it have been missing. So far, I have never installed a Python 3.3 and I have never seen the Gvim complaining about the missing python33.dll. This also confused me.

Nevertheless, I still cannot get Vim to work with "a proper Python distribution".

Help needed!

Inexperienced with program developing, I am really having a hard time debugging this issue. Any advice would help!

As of now, I am trying to set up a complete installation of Cygwin, in hope that it may build a local Vim distribution; also, I am also attempting to pursue another route: to compile the source file of Vim using Visual Studio. Simply completely installing these two softwares takes hours.

Hope someone may help!

All the best,

-Linfeng

llinfeng

Posted 2016-07-05T19:10:14.230

Reputation: 461

In completion of the Downloading links: 1. The plain Vim version from Vim Cream, accessible from: https://sourceforge.net/projects/cream/files/Vim/ 2. The "official", yet obsolete Vim installer, from: http://vim.sourceforge.net/download.php#pc 3. "Home built" Vim distributions released by kindhearted individuals:

– llinfeng – 2016-07-05T19:10:26.870

Installing a complete Cygwin is not recommended. There are ~ 4000 packages mostly irrelevant to your need. Cygwin has vim, gvim and python, but I have not understood what are you really looking for. – matzeri – 2016-07-05T21:23:22.293

To clarify: I would like to have a gvim.exe with Python enabled. As described, I failed to achieve so. Basically, I can find all the check marks for +python/dyn and +python3/dyn through command :version, yet get the error message for :python being disabled. – llinfeng – 2016-07-06T02:46:25.607

@matzeri: thanks for pointing out the redundant packages for Cygwin. I plan to use it to build a python-enabled gvim.exe. Though, I have no idea if this may work. Days have been spent on this issue already, after I "upgraded" from Windows 8.1 to Windows 10. – llinfeng – 2016-07-06T02:48:08.740

Install a vim binary from here and don't forget to install the required python interpreter as well.

– Christian Brabandt – 2016-07-07T07:38:56.040

Indeed, this binary installer looks appealing! At minimum, it has all the reference on how to install ALL supporting libraries. Will update the question post with all the installation options once I have 10 points for reputation. (As of now, I cannot include more than two URLs in my question.) Thank you! – llinfeng – 2016-07-07T11:51:11.390

Not sure why I was planning to include more than two URLs, but what follows goes my current understanding of this old problem. – llinfeng – 2017-08-30T14:36:46.787

Answers

0

Longer explanation

Long story spoken in the long way: what has been missing is not the "Python support" part (+python/dyn and +python3/dyn). Nearly all GVim installers available to the Windows users have built-in Python support. What has been really missing, is that Python don't know how to call the Python program. Thus, all you need to do is to guide a Python-enabled GVim to find python.exe.

Short solution

Add the following line to the _vimrc:

  • let $PYTHONHOME = 'C:/Users/UserName/AppData/Local/Continuum/Anaconda2/'

Generalized solution

In short, you need to first find any folder that contains python.exe. Then, please specify the $PYTHONHOME path correctly to such folder.

llinfeng

Posted 2016-07-05T19:10:14.230

Reputation: 461