dounaoji2054
dounaoji2054
2014-06-26 16:47

Windows Vim YouCompleteMe自动完成

已采纳

Although there's no official support for windows environment it seems that numerous people have been successful in getting this work. I desparately trying too but without success.
All what I need now is working autocompletion for php files (omni-completion, keyword completion).

I'm running x64bit version of compiled Vim 74 (+python27, +python33) here
From same guy I downloaded YouCompleteMe compiled for windows here

I installed plugin as always with pathogen plugin. I've installed Python27 & Python33 (x64) and I've both placed in my PATH. (Also python27.dll in windows/System32/directory)

In this state. if I ran Vim, I was getting error:

"The ycmd server SHUT DOWN (restart with ...). Stder (last 30 lines)..."

on vim startup. In same time Error log said:

RuntimeError: Error importing ycm_core. Are you sure you have placed a version 3.2+ libclang.[so|dll|dylib] in folder "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python"?

So I provided libclang.dll in specific folder (x64bit version) although I was editing a php file (not c family file) so this isn't relevant. Is it?

OK so now I'm in situation where I still get error on startup:

"The ycmd server SHUT DOWN (restart with ...). Stder (last 30 lines)..."

but Error log has been changed, it says:

DEBUG - No global extra conf, not calling method YcmCorePreload
Traceback (most recent call last): File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server../..\ycm\server\handlers.py", line 23, in
import ycm_core ImportError: Module use of python27.dll conflicts with this version of Python.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server/ycmd.py", line 126, in
Main() File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server/ycmd.py", line 115, in Main from ycm.server import handlers File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server../..\ycm\server\handlers.py", line 30, in str( e ) ) ) RuntimeError: Error importing ycm_core. Are you sure you have placed a version 3.2+ libclang.[so|dll|dylib] in folder "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python"? See the Installation Guide in the docs. Full error: Module use of python27.dll conflicts with this version of Python.

What does it meen? I'm pretty sure that I've required version (Python 277 x64bit).
What can I do? Could someone help me who got this working on windows environment?

UPDATE:

@sooop's answer pushed me a little bit forward, it helped.
Problem was that in PATH I had in front of "c:\Python27" placed "c:\Python33". So it found first provided python version and quit searching for Py27. So I placed "c:\Python27" before "c:\Python33" and this message disappeared.

Unfortunately another error occured: Now error log says:

File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server../..\ycm\server\handlers.py", line 23, in import ycm_core ImportError: DLL load failed: %1 is not a valid Win32 application.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server/ycmd.py", line 126, in Main() File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server/ycmd.py", line 115, in Main from ycm.server import handlers File "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python\ycm\server../..\ycm\server\handlers.py", line 30, in str( e ) ) ) RuntimeError: Error importing ycm_core. Are you sure you have placed a version 3.2+ libclang.[so|dll|dylib] in folder "C:\Program Files\Vim\vimfiles\bundle\you-complete-me\python"? See the Installation Guide in the docs. Full error: DLL load failed: %1 is not a valid Win32 application.

Unfortunately I do not know what to do at all as well.

SOLUTION

@sooop's answer solves both of the two last errors. YouCompleteMe plugin supports only Python27 (and Py26). And path to the "\Python27\python.exe" in %PATH% environment variable must be at the first position, in front of other python versions!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dongyan3237 dongyan3237 7年前

    Remove path th python3 from your %PATH%.

    点赞 评论 复制链接分享
  • doujing5150 doujing5150 5年前

    An alternative and IMHO cleaner solution is to refer ycm to you python executable explicitly. To do so, put the following in your .vimrc:

    let g:ycm_path_to_python_interpreter = 'c:\Python27_64\python.exe'
    

    where c:\Python27_64\python.exe should be replaced by the full path to your python executable. Note that its architecture (i.e. 32 or 64 bit) should match your vim architecture.

    点赞 评论 复制链接分享

为你推荐