我在让 Python 3 在 vim 中工作时遇到了真正的麻烦。我已经从vim github下载了最新的8.0源代码,并且我一直在使用它进行配置,使用包括Python 3.6在内的Anaconda发行版:
./configure
--with-features=huge
--enable-multibyte
--enable-cscope
--enable-multibyte
--enable-python3interp=yes
--with-features=huge
--with-python3-config-dir=$ANACONDA_PATH/lib/python3.6/config-3.6m-x86_64-linux-gnu
--enable-fail-if-missing
--prefix=$LOCAL_BIN
按照通常的方式(make -j
(,安装,然后运行,测试Python 3
包含:
:python3 import sys
然后我得到了一个SIGABRT
杀戮的vim。我添加了 Vundleklen/python-mode
,它在启动时杀死了 vim:
Fatal Python error: PyThreadState_Get: no current thread
我看到很多人在OS X上使用YCM时遇到此错误,MacPorts/系统捆绑版本的Python感到困惑。这里似乎不是这种情况,我正在运行一台运行 3.16 内核的 Debian 机器,检查vim --version
显示 python3 被正确编译,并且它指向 python3.6 库的正确区域(/usr/local/lib
中没有冲突(:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug 19 2017 11:46:55)
Included patches: 1-966
Compiled by Matt
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
-balloon_eval +folding +mouse_xterm +termguicolors
-browse -footer +multi_byte -terminal
++builtin_terms +fork() +multi_lang +terminfo
+byte_offset +gettext -mzscheme +termresponse
+channel -hangul_input +netbeans_intg +textobjects
+cindent +iconv +num64 +timers
+clientserver +insert_expand +packages +title
+clipboard +job +path_extra -toolbar
+cmdline_compl +jumplist -perl +user_commands
+cmdline_hist +keymap +persistent_undo +vertsplit
+cmdline_info +lambda +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak -python +viminfo
+cscope +lispindent +python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu -ruby +writebackup
+digraphs +mksession +scrollbind +X11
-dnd +modify_fname +signs +xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape +startuptime -xpm
+eval +mouse_dec +statusline +xsmp_interact
+ex_extra -mouse_gpm -sun_workshop +xterm_clipboard
+extra_search -mouse_jsbterm +syntax -xterm_save
+farsi +mouse_netterm +tag_binary
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/home/matt/.local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -ldl -L/home/matt/anaconda3/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lrt -lm
我还通过gdb
运行了这个编译的实例,info shared
显示正确的libpython3.6
是从我的 anaconda 目录加载的。我真的迷茫了。谁能想到我错过了什么?
所以我今天正在处理同样的问题,我设法通过配置 VIM 编译来修复它
--enable-python3interp=dynamic
我在 https://github.com/Valloric/YouCompleteMe/issues/2855 找到了建议。在我的网站上,我什至不需要干涉LD_LIBRARY_PATH
或类似的东西。