6

How do I install GVIM for Windows with Python3 support? I have installed VIM 7.4 which says in it's version file (run :version command) "+python3/dyn" and "-DDYNAMIC_PYTHON3_DLL=\"python32.dll\". So it looks like it's ready to support Python 3. When I run

:echo has("python3")

it returns zero. And if I test with

:py3 print("hello") 

it says it cannot load python32.dll.

5 Answers 5

14

Here is an approach that I used to get VIM 7.x to work with Python 3.x.

  1. Install a VIM of your preference. Suggestion: get the latest version from VIM.org, though this site seems to have only 32-bit versions. If you want 64-bit (my preference) get a pre-built at https://bintray.com/veegee/generic/vim_x64 or choose your own pre-built elsewhere, or build your own.

  2. Type the command :py3 print("hello")

  3. It probably will not find the python dll, in which case it gives an error message like cannot load pythonXX.dll where XX is a two-digit number. In my case, VIM was looking for python35.dll, which comes from Python 3.5.1 (and probably any Python 3.5.x). The number will vary depending on the version of VIM you use.

  4. Go find a matching Python distribution. Matching means that both VIM and Python must be either 32-bit or 64-bit, and the DLL that VIM wants (in step 3) is present. So for example, it appears that Python 3.5.x provides python35.dll. Install it.

    1. I don't recall having to do anything special to get VIM to find the python DLL, other than ensuring that the directory it is in should be in the path, and I think it already was. If not, add the directory with the DLL to your path.

    2. Retry step 2. It should work now.

    3. If in the future you upgrade VIM or Python, you may need to upgrade the other one at the same time, to ensure that the test in step 2 still works.

9

The problem that makes this question so hard is that specific solutions very quickly become obsolete. The day the solution is posted the version of vim or python is updated or links change. The steps provided by @mark-colon are fantastic but oriented for vim-7.

Generic instructions:

vim and python need to be in sync on many different levels:

  1. Both need to be 32bit or 64bit

  2. Vim needs to find a specific python dll version. It depends on who compiled your version of gvim. For example, gvim-8.1.x may use python3.6 or python3.7 and the exact version is required! Sometimes you can use: gvim --version to see what specific dll is being searched by vim at launch, otherwise you need to find out from where you downloaded gvim. This is the version of python that you must search the internet and install on your system. (Alternatively, if the version of python is more important to you than the version of vim, you can try to find a version of vim that was compiled for python but this will be harder to find.)

  3. Make sure the directory that holds the python dll needs to be on the %PATH% environment variable. (Note: some just copying the python dll to the $VIM folder to get things working only works in the short term. You don't have all the necessary python libraries that are often assumed to be available.)

  4. Finally, verify with ex command :python2 print("hello") or :python3 print("hello") depending on what version of python you wanted.

Specific links (if you must):

Note: these will all soon be out of date, but the following are some links to various compiled versions of gvim and python that could work together:

For gvim-8.1.x & python-3.7.x or python-2.7.x as of 2018-08:

For gvim-8.1.x & python-3.6.x or python-2.7.x as of 2018-08:

For gvim-7.4.x & python-3.5.x or python-2.7.x as of 2018-08:

1
  • in vim execute :py3 print('hi'), the error message contains enough information about the version of python vim is looking for (say 3.6). then check :version to see what version of gim you are running (probably 32). finally, head over to python and get the right version / arch installer (say 32 biy python 3.6). I install python as admin, and vim has no issues finding it.
    – ricardo
    Aug 29, 2018 at 0:41
3

Unfortunately this took me a day to figure out. Here's the simplest way to remedy this problem, if you are looking to have Python3 support with GVIM 7.3+ on Windows.

I am running 64-bit Windows 8, but, make sure you grab a 32-bit version of Python. You will most likely have a 32-bit version of GVIM by default, and those 2 need to match. Specifically, grab a 3.2.x version of Python3 because that's what VIM is looking for as far as a DLL is concerned (python32.dll). Don't bother with the latest version of Python 3, 3.4.0 at the time of writing; and if you do need that, then I'm not sure how to help.

Once you have Python 3.2.x installed, make sure you do this last tricky part:

The python32.dll is not placed in system32 folder, it is actually in the C:\Windows\SysWOW64 folder. You need to add "C:\Windows\SysWOW64" to your PATH environment variable.

Now re-try your python3 tests in GVIM and it should be successful.

1
  • For those that find this nowadays, this solution specifically applies to the Vim7.4 distribution available today (July 2016) from vim.org. Jul 26, 2016 at 2:55
1

I use Haroogan's compiled version, it's great and has a 64-bit version for windows.

EDIT:

veegee's version seems to be a good alternative. Thanks to Markus Meskanen in the comment.

1
  • Use veegee's instead. He's an awesome guy who's always willing to compile Vim for the latest Python as soon as you notify him about it. Aug 12, 2016 at 8:47
0

I have tested that you should use the same architecture for both vim and python. see https://vi.stackexchange.com/questions/11004/how-to-get-python-support

If you just need python feature in vim, download python36.dll and put in $VIM and verify by :echo has('python3')

Your Answer

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

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