#0
YouCompleteMe是vim文字編輯器一個很強大的外掛
不過本篇不是要介紹這個外掛,只是個錯誤問題的解決記錄而已…XD
由於先前安裝這個plugin,執行vim總會出現這個訊息:
# vim
YouCompleteMe unavailable: requires python 2.x
Press ENTER or type command to continue
我以為是系統預設使用Python3所造成的錯誤,用eselect可以看系統目前預設使用的python版本
# eselect python list
Available Python interpreters:
[1] python2.7
[2] python3.2 *
所以我用 eselect python set python2.7 將預設的python切換到2.7的版本
想不到錯誤訊息依舊!!
最後搜尋一下網路資料,才了解這邊的python版本指的是vim有沒有python-support
從指令 vim –version 可以發現:
# vim –version
VIM – Vi IMproved 7.3 (2010 Aug 15, compiled Dec 6 2013 14:38:07)
Included patches: 1-762
Modified by Gentoo-7.3.762
Compiled by Ted
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_sgr -mouse_sysmouse
+mouse_urxvt +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile -python
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
其中你可以看到上面標註紅字的「-python」,就是這個問題的主要原因
解決方法其實很簡單,讓vim支援python就可以了
在Gentoo裡面可以使用USE flag,重新emerge即可!
# USE=”python” emerge vim
重新使用 vim –version在看一次:
+mouse_urxvt +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile +python
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
問題解決,打完收工