1

As an extension (follow-up question) of the answer here:

If you type :version, you should see +python/dyn and +python3/dyn. On Windows, this means that Vim is compiled to dynamically load the Python DLL. You can read about this in :h python-dyanmic. Depending on the versions you install, you may want to look at :h pythondll and :h pythonthreedll

If you install Python 3, keep in mind that you will need to verify it with :echo has('python3'). Additionally, if you want to install both Python 2 and 3, you will want to read :h has-python.

I've checked the version settings and ensured the existence of both +python/dyn and +python3/dyn. I have the latest distribution of Python 3 (which, at this time, is 3.7.2), and have installed a 32-bit version of it so that it's compatible to my 32-bit gVim 8.1, as per the comment in the quoted answer:

Also be sure to use a 32-bit python with a 32-bit vim, or use a 64-bit version of both. If you mix them, vim will not be able to load the dll.

However, even after several reboots and re-installations, the command :echo has('python3') still returns 0. How can I make sure that Python 3 is supported on Vim?

I just wanted to use that YCM plugin...

  • What's the output of :set pythonthreedll?? – Ralf Jan 29 at 6:32
  • It's =python36.dll. – K. Paul Jan 29 at 12:07
  • I guess the dll in 3.7.2 is python37.dll. Try set pythonthreedll=python37.dll. If that doesn't work use the full path. – Ralf Jan 29 at 12:43
3

With dynamic python, the name of the python DLL (or shared object on Unix) is defined at compile time. In your case it is python36.dll. As you now want to use a different python version, this name needs to be changed.

For this Vim has the option pythonthreedll (and pythondll for python2). Set it to the name of DLL you want to load.

Add the following to your vimrc:

set pythonthreedll=python37.dll

If this doesn't work you can also set the full path to that library. In that case you might also need to set pythonthreehome:

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

AFAIK this second way is needed, when python was not installed but just unpacked. In that case, the DLL is not registered to Windows and hence can't be found by name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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