vim-ipython failed on Windows 7

心不动则不痛 提交于 2019-12-12 02:52:10

问题


I installed iPython by Anaconda on Windows 7. (There's no python installed previously). I can run ipython without problem.

Then I installed vim-ipython plugin. In vim, when I run

:IPython

I got this:

E492 Not an editor command.

I checked vim version:

:version
+python/dyn

I checked (in vim)

:python import sys
E370 Could not load python27.dll

Run python on cmd:

Python 2.7.5 |Anaconda 1.7.0 (64-bit)| (default, Jul  1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)]

Could you please tell me what is wrong with this installation? Thank you.

Edit: I tried (in Vim):

:echo has("python")
0

I get really confused!

Edit 2: Thanks for everybody's help. I decide to build/compile vim 64-bit on windows. I've downloaded MinGW-w64, but don't know how to use it: I can't find 'make'. (I remember there's mingw-32-make in the 32 bit version, but none in the 64-bit version.)


回答1:


On windows for vim to find python DLL path to it must be present in $PATH. There are multiple ways to achieve this:

  1. Editing registry. On wine I achieve this by adding a new path to the value of PATH key stored inHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment by creating path.reg file:

    REGEDIT4
    
    [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]
    "PATH"="{put old value of %PATH% here};C:\\path\\to\\python\\dll"
    

    and running regedit path.reg, but I guess HKEY_LOCAL_MACHINE is a bit of overkill and you need something under HKEY_CURRENT_USER. I am using it with wine (windows emulator) anyway so I do not care. You can launch regedit without arguments and try to find something there.

  2. AFAIR there is a way to set %PATH% in a link file you use to launch vim.
  3. Maybe just putting the following into the vimrc will work:

    let $PATH.=';C:\path\to\python\dll'
    

Note: none of the advices will work if vim was compiled with different python version support. Also if some configure flags (e.g. debugging support) differ between python from anaconda installer and python used by the whoever compiled vim error message should change. I do not know whether error message will change if vim is 32-bit and your python is 64-bit, but loading python will for sure fail in this case.




回答2:


Your troubleshooting output shows that your Vim is compiled with dynamically loaded Python (+python/dyn), but the error you get and has('python') == 0 means that the Python interpreter cannot be successfully loaded. The IPython plugin probably has a guard clause that prevents its loading unless Python is available.

You need to fix the Python integration into Vim, either by making that DLL available to Vim (so that there'll be no errors and has('python') == 1), or (as a last resort) compiling Vim yourself.



来源:https://stackoverflow.com/questions/19205281/vim-ipython-failed-on-windows-7

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