How to install gvim.exe on Windows with Python support?
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.
- The plain Vim version from Vim Cream.
- The "official", yet obsolete Vim installer.
- "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.
- Ref 1:
- Ref 2:
Restriction 2: The order of installation
The
gvim.exeshall need to see thepython27.dlland thepython33.dll. (This is accessible through:versionin 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 thepython33.dllavailable on my machine. Yet,gvim.exemay only complain aboutpython27.dllshould it have been missing. So far, I have never installed a Python 3.3 and I have never seen the Gvim complaining about the missingpython33.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
71 Answer
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.