Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gvim can not load my Python

Tags:

python

vim

I wanna use gvim (on windows 7) as my Python IDE, but gvim can not load my python. My os is Windows 7 X64 with SP1, I use Python35 (64)

I run :version in gvim, the output includes:

....

+python/dyn

+python3/dyn

...

Compilation: ...

-DFEAT_PYTHON -DDYNMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python35.dll\"

....

It means this gvim compiled with python and python3 support , but when I run

:echo has("python")

or

:echo has("python3")

both return 0

the result of :python print(3) is :

E370: Could not load library python27.dll

E263: Sorry,this command is disabled,the Python library could not be loaded.

My python35 directory is C:\Python35 ,and it is in my PATH.

Why is this ? Does gvim only search for python27 ,not python35 ?

I follow this vim-ipython-failed-on-windows-7 and try to edit my registry ,but it did not work.

Do I have to recompile gvim myself ,or should I give up gvim ?

like image 413
Mr.Bingo Avatar asked Apr 01 '17 09:04

Mr.Bingo


3 Answers

I had this problem also. I reinstalled python several times, made sure that both python and Vim were the same architecture (both 32bit) with no success. The only thing that solved it was to copy python27.dll into Vim's directory. A bit crude but it works!

like image 59
Tiago Paixao Avatar answered Nov 11 '22 19:11

Tiago Paixao


Your problem as someone else mentioned in passing is that you are using gvim--which is 32-bit only; there used to be 64-bit gvim build but was discontinued (vim.org says so). If you have "+python/dyn" and "+python3\dyn" (default as of 8.1 gvim binary from vim.org) then vim just needs to know where the 32-bit (not 64-bit like you said you have installed) version of python36.dll is (name it looks for it in gvim 8.1). If you can open up cmd.exe and run 'python' and you get a python 3 prompt then python36.dll is available on your path and gvim will know where to find it. I had the same issue, but uninstalling 64-bit version and reinstalling python 3.6.6 from python.org using x86 version, gvim picked it up and it worked. Try a quick :py3 print('hello') and if you get "hello" echo'd back, then everything is set up right.

like image 45
cmaceachern Avatar answered Nov 11 '22 19:11

cmaceachern


The :python command will use the Python 2[.7] interpreter. As you only have installed Python 3[.5], you need to use the :python3 / :py3 command.

like image 26
Ingo Karkat Avatar answered Nov 11 '22 18:11

Ingo Karkat