vim could not load library python27.dll

11

4

I need Windows 7 + vim + python for writing vim plugins.

:python print("hello")
E370: Could not load library python27.dll
E263: Sorry, this command is disabled, the Python library could not be loaded.

Tried everything:

  • reinstalled vim
  • uninstalled all my 64bit python versions and installed 32bit ones
  • reinstalled vim again
  • restarted computer
  • punched desk and keyboard
  • restarted computer

Andriy Drozdyuk

Posted 2011-08-11T20:55:31.483

Reputation: 315

For all those having the same problem: installing "cream" fixes it: http://cream.sourceforge.net Yes - this question will probably get closed - but the fact is that there is still no solution to this anywhere on the web.

– Andriy Drozdyuk – 2011-08-11T21:00:51.417

Answering your own question is good, but post it as an answer, not a comment, then accept it after two days. – None – 2011-08-11T21:03:25.097

compile it with python support – Eric Fortis – 2011-08-11T21:52:10.867

Hm... I am not compiling it, but rather downloading an installer. – Andriy Drozdyuk – 2011-08-11T22:52:36.310

@drozzy: there are installers here: https://bintray.com/veegee/generic/vim_x64. Had the same problem as you and didn't want to build Vim on my own. Simple!

– eckes – 2013-09-26T13:34:34.107

Official x64 version is kept here nowadays: http://code.google.com/p/vim-win3264/

– Antony Hatchkins – 2013-11-15T18:26:01.723

Answers

2

Ok here it goes: For some reason installing "cream" fixes it: cream.sourceforge.net.

:python print("hello")
hello

Interestingly enough, "cream" includes a regular version of "gvim" - so I can use just that.

Andriy Drozdyuk

Posted 2011-08-11T20:55:31.483

Reputation: 315

13

Diagnostics

:version will show you if you have 32bit vim or 64bit
python.exe will show you if you have 32bit or 64bit python.

Resolution

Now it's up to you to choose either:

  • 32bit vim + 32bit python or

  • 64bit vim + 64bit python

otherwise it won't work complaining with the error you quoted.

NB Latest 64bit vim cannot be downloaded from the download page anymore. For some mysterious reason now there's a new special page for that:

http://vim.wikia.com/wiki/Where_to_download_Vim

Antony Hatchkins

Posted 2011-08-11T20:55:31.483

Reputation: 321

5

Are you sure that you installed the same version of 32 bit python that Vim was looking for? I see no reason that this wouldn't have fixed your problem, unless you somehow had a gvim exe built without python support. Anyway, I had precisely this problem, and the obvious thing to me was that my python dll was x64, whilst I had 32 bit vim. The solution for me was simply to build a 64 bit version of Vim. I much prefer upgrading Vim to downgrading Python. The arguments I sent to the make file were:

nmake -f Make_mvc.mak GUI=yes CPU=AMD64 PYTHON=C:\Python27 DYNAMIC_PYTHON=yes PYTHON_VER=27

I then replaced my original 32 bit gvim.exe with the 64 bit one I just built. Everything worked perfectly. If you are worried about the hassle of the build, don't be- it was very straightforward using visual studio 2010's compilers, and running make from the appropriate visual studio command prompt (x64 cross tools). I can send further instructions if needed.

wes

Posted 2011-08-11T20:55:31.483

Reputation: 51

i was exactly in your situation. since i didn't want to recompile vim, i installed the 32bit version of python 2.7 and now gvim works like a charm! – apelliciari – 2012-04-02T23:05:55.073

There's a precompiled x64 version (linked from vim.org download page), installing it resolves the problem. – Antony Hatchkins – 2013-11-15T18:27:11.390

2

An alternate solution that I have not seen mentioned that worked for me.

1. as the other answers state, make sure that the python version matches the 32/64 bit.

2. add set pythondll=FULL_PATH_TO_THE_APPROPRIATE_PYTHON.DLL to your .vimrc

for example: set pythondll=E:\\extern\\python27-32\\python27.dll

3. reload the vimrc by either closing and restarting vim, or using :source $MYVIMRC

other tidbits:

  • to find out where your .vimrc is :echo $MYVIMRC

  • to easily edit your .vimrc :e $MYVIMRC

  • to see what it is set to :options then /pythondll or :set pythondll?

  • to test that it worked :py import sys followed by :py print('Happy')

More Info:

:help python-dynamic

:help pythondll

:help options

:help source

:help $MYVIMRC

edit:

Jon Plotner

Posted 2011-08-11T20:55:31.483

Reputation: 21

On Vim 8.0 this works only without quotes (') or double quotes ("). Obviously, you path should not contain any spaces :/ – Boris Brodski – 2018-03-19T09:57:26.640

good point BorisBrodski. I changed the quotes to backticks to help with any confusion. – Jon Plotner – 2019-12-27T07:18:05.800

1

I had this problem with VIM 7.2 looking for the python25.dll This was fixed by adding the path to the python25.dll file (c:\python25\ on my system) to the PATH environment variable.

Willem van Ketwich

Posted 2011-08-11T20:55:31.483

Reputation: 111

0

There is a similar question: Google drive error : python27.dll

Problem is in python27.dll dependencies. You can check this by dependencywalker utility. Missed dll is "msvcr90.dll". It comes with "Microsoft Visual C++ 2008 Redistributable Package" and Windows 7 does not include it even with all installed updates. You should install this package manually from:

Windows 7 x64: https://www.microsoft.com/en-us/download/details.aspx?id=15336

Windows 7 32 bit: https://www.microsoft.com/en-US/download/details.aspx?id=29

Eugene Belyakov

Posted 2011-08-11T20:55:31.483

Reputation: 1

OP had already a better solution – yass – 2017-05-18T20:01:03.070

0

If you want to keep your 64-bit version of Python, at this moment, an easy to install and recent version of Vim64 for Windows can be found here. It even uninstalls your existing 32-bit gvim for you.

Aurel Wisse

Posted 2011-08-11T20:55:31.483

Reputation: 1