1

My machines have Python 3.7 installed. On my Ubuntu machine I have no issues, but on my Windows 10 machine, I can't run Python plugins in Vim. The reason is that the Windows Vim as distributed has been compiled for Python 3.6, and Vim will only use the Python version that was specified at compilation time.

My question is this: Why does it matter which Python version I use, as long as the scripts are compatible? Why try to embed a part of Python in the program (a DLL on Windows), instead of either embedding the whole thing or--better yet--just calling out to the python executable? Then the version doesn't matter.

FYI: I've tried to build my own Vim on Windows, but it seems that the documentation on how to do so is quite outdated and building software on Windows is incredibly difficult (install a text editor to get a compiler?!).

2
  • windows vim distributed where? the releases here (linked from the vim home page) github.com/vim/vim-win32-installer/releases work with python 3.7
    – Mass
    Commented Jan 18, 2019 at 1:34
  • 1
    This is Vim 8.1.1 from the Vim official download page. When running :version, the compilation line includes -DDYNAMIC_PYTHON3_DLL=\"python36.dll\", so the current release as distributed isn't built with Python 3.7. Commented Jan 18, 2019 at 1:50

1 Answer 1

3

Vim can be build with static python or dynamic python support. If it is build with dynamic python you are able to change the python version.

Just look at the output of :version. If it contains +python/dyn and +python3/dyn, it is compiled for dynamic python. Then you are able to change the python dll to use by changing the option pythondll or pythonthreedll:

set pythonthreedll=python37.dll

If Vim is not compiled with dynamic python support, this will result in an error message, as the option doesn't exist then.

Note: If python is not installed, but only unpacked from a zip, Vim is not able to find it that way. Then you need:

set pythonthreehome=C:\path\to\python
set pythonthreedll=C:\path\to\python\python37.dll

Also useful if you have multiple python installations.

As already mentioned in a comment, a up-to-date version of Vim for Windows with dynamic python support, can be downloaded from this github page.

See :help python-dynamic and help for the named options.

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.