求 pyenv 和 YCM 正确打开方式
Closed this issue · 4 comments
caimaoy commented
前几天手残看了 pyenv 介绍觉得不错,就装上了,用了一些也觉得不错,但是到了要写代码的时候就 gg 了。发现 YCM 似乎某些东西配置有问题 HELP
环境:MAC pyenv
MacOS X (unix) version
Included patches: 1-525
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +find_in_path -mouse_sysmouse -tag_any_white
+arabic +float +mouse_urxvt +tcl
+autocmd +folding +mouse_xterm +termguicolors
+balloon_eval -footer +multi_byte +terminfo
+browse +fork() +multi_lang +termresponse
++builtin_terms +fullscreen -mzscheme +textobjects
+byte_offset -gettext +netbeans_intg +timers
+channel -hangul_input +num64 +title
+cindent +iconv +odbeditor +toolbar
+clientserver +insert_expand +packages +transparency
+clipboard +job +path_extra +user_commands
+cmdline_compl +jumplist +perl +vertsplit
+cmdline_hist +keymap +persistent_undo +virtualedit
+cmdline_info +lambda +postscript +visual
+comments +langmap +printer +visualextra
+conceal +libcall +profile +viminfo
+cryptv +linebreak +python +vreplace
+cscope +lispindent -python3 +wildignore
+cursorbind +listcmds +quickfix +wildmenu
+cursorshape +localmap +reltime +windows
+dialog_con_gui -lua +rightleft +writebackup
+diff +menu +ruby -X11
+digraphs +mksession +scrollbind -xfontset
+dnd +modify_fname +signs +xim
-ebcdic +mouse +smartindent -xpm
+emacs_tags +mouseshape +startuptime -xsmp
+eval +mouse_dec +statusline -xterm_clipboard
+ex_extra -mouse_gpm -sun_workshop -xterm_save
+extra_search -mouse_jsbterm +syntax
+farsi +mouse_netterm +tag_binary
+file_in_path +mouse_sgr +tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X_UNIX -F/usr/local/opt/python/Frameworks -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -L/usr/local/lib -L. -L/usr/local/lib -F/usr/local/opt/python/Frameworks -L/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework CoreFoundation -L/usr/local/lib -o
Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -F/usr/local/opt/python/Frameworks -framework Python -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby
❯ cat /var/folders/m1/04wv1cbj7b7gtpslrqzqh3580000gn/T/ycm_temp/server_63282_stderr.log
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 187, in <module>
Main()
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 159, in Main
extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists()
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/extra_conf_store.py", line 73, in CallGlobalExtraConfYcmCorePreloadIfExists
_CallGlobalExtraConfMethod( 'YcmCorePreload' )
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/extra_conf_store.py", line 91, in _CallGlobalExtraConfMethod
module = Load( global_ycm_extra_conf, force = True )
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/extra_conf_store.py", line 149, in Load
module = LoadPythonSource( _RandomName(), module_file )
File "/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/utils.py", line 388, in LoadPythonSource
return imp.load_source( name, pathname )
File "/Users/caimaoy/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py", line 32, in <module>
import ycm_core
ImportError: dlopen(/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycm_core.so, 2): no suitable image found. Did find:
/Users/caimaoy/reps/k-vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycm_core.so: mach-o, but wrong architecture
添加了这两个变量,也没有用
let g:ycm_server_python_interpreter = '/usr/bin/python'
let g:ycm_path_to_python_interpreter = '/Users/caimaoy/.pyenv/shims/python'
YCM 是不是需要重新编译?
求指导
PS:和 YCM 抗争了许久,从 Windows 到 Mac,从虚拟环境到 pyenv, 估计还要从 python2 到 python3 。。。
LittleKey commented
不用自己指定interpreter路径也行的吧。。
pyenv生成virtualenv,然后跑pyenv activate xxxx应该就行了
p.s 我现在直接用maralla/completor.vim ycm删了挺好的
caimaoy commented
@LittleKey 看起来不错,需要 vim8 是吗?看来又要折腾好久
LittleKey commented
很简单的mac下直接brew就能装,记得带几个参数设为系统默认的(最好装vim-python3的支持,加个参数就行了
caimaoy commented
pyenv "--enable-framework" 安装 2.7.11, 2.7.10 安装不成功,2.7.13 好像可以,然后去掉
let g:ycm_server_python_interpreter = '/usr/bin/python'
let g:ycm_path_to_python_interpreter = '/Users/caimaoy/.pyenv/shims/python'
重新编译 YCM,貌似可以,但是之前的虚拟环境好像不可以,可能要改改配置
先关单了