Gvim can not load my Python

偶尔善良 提交于 2019-12-14 00:24:17

问题


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 ?


回答1:


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!




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/43154883/gvim-can-not-load-my-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!