Since many Vim plugins depend on Python; updating Vim often requires a Python update. We will see how to resolve such plugin dependencies using an embeddable Python distribution.
Does Python already work?
Before starting, check whether you happen to have the correct version of Python installed.
If this prints 1 then you are good; no need to embed Python.
Was Vim compiled with Python support?
Check whether your Vim was compiled with Python support.
Check for a plus sign before python3/dyn. If there is a minus sign before python3/dyn that means your Vim was not compiled with Python 3 support. You will have to install a Vim build with Python support. Vim nightly builds with Python support can be found here https://github.com/vim/vim-win32-installer. This is a repository maintained by Christian Brabandt, a major contributor to Vim. It contains both 32bit and 64bit builds of Vim. To know about other download options, please visit https://vim.fandom.com/wiki/Where_to_download_Vim
Which version of Python is needed?
The Python version is usually mentioned in the build repositories. You can also run a sample Python command to see which version of Python you need.
This would echo an error message like this:
E370: Could not load library python36.dll: The specified module could not be found. E263: Sorry, this command is disabled, the Python library could not be loaded.
In this example, Vim is expecting python36.dll, so we need Python 3.6.
32-bit or 64-bit Python
For 32-bit Vim you need 32-bit Python and for 64-bit Vim you need 64-bit Python. You can use the version command to check which version of Vim you have.
Download embeddable Python
Embeddable versions of Python can be downloaded from the official site https://www.python.org/downloads/windows/.
Link Vim and Python
Extract the Python zip archive in any folder of your choice. Set up Python paths in your vimrc like so:
set pythonthreehome=C:/PortableApps/python-3.6.4-embed-win32 set pythonthreedll=C:/PortableApps/python-3.6.4-embed-win32/python36.dll
Now you should be able to use Python from inside Vim.
" should print 1 echo has('python3') " should print hello py3 print('hello')