python - vim: 无法加载库 libpython

标签 python vim

我没有让 vim 与 python 支持一起工作。我使用以下配置编译 vim 7.4.972:

./configure --enable-shared --with-features=huge --enable-multibyte --enable-cscope
    --enable-rubyinterp=yes --enable-pythoninterp=yes --enable-python3interp=yes
    --enable-perlinterp=yes --enable-luainterp=yes --enable-gui=auto
    --enable-gtk2-check --enable-gnome-check --prefix=/home/me/tools/
    --with-global-runtime=/home/me/tools/share/vim/vim74 --with-lua-prefix=/home/me/tools
    --with-luajit --enable-fail-if-missing -with-x | tee vim_conf.log

关于 python 的输出是:

checking --enable-pythoninterp argument... yes
checking for python2... /sw/python/anaconda/bin/python2
checking Python version... 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... /sw/python/anaconda
checking Python's execution prefix... /sw/python/anaconda
checking Python's configuration directory... /sw/python/anaconda    /lib/python2.7/config
checking if -pthread should be used... yes
checking if compile and link flags for Python are sane... yes
checking --enable-python3interp argument... yes
checking for python3... /sw/python/anaconda3-2.2.0/bin/python3
checking Python version... 3.4
checking Python is 3.0 or better... yep
checking Python's abiflags... m
checking Python's install prefix... /sw/python/anaconda3-2.2.0
checking Python's execution prefix... /sw/python/anaconda3-2.2.0
checking Python's configuration directory... /sw/python/anaconda3-2.2.0    /lib/python3.4/config-3.4m
checking if -pthread should be used... yes
checking if compile and link flags for Python 3 are sane... yes
checking whether we can do without RTLD_GLOBAL for Python... yes
checking whether we can do without RTLD_GLOBAL for Python3... yes

vim --version 显示:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 16 2015 10:47:42)
Included patches: 1-972
Compiled by ziereisen@l57
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    +xpm
   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"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/ziereisen/tools/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12   -DORBIT2=1 -pthread -I/usr/include/libgnomeui-2.0 -I/usr/include/libgnome-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gtk-2.0 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/libbonoboui-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib64/gnome-vfs-2.0/include -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/orbit-2.0 -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include/libxml2     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc -L/lib64    -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/sw/perl5/lib/5.8.8/x86_64-linux-thread-multi-ld/CORE   -L/usr/local/lib -Wl,--as-needed -o vim   -L/lib64 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0   -L/lib64   -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnome-keyring -lxml2 -lz -lgnomecanvas-2 -lgnome-2 -lpopt -lart_lgpl_2 -lpangoft2-1.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lbonobo-2 -lgnomevfs-2 -lbonobo-activation -lgconf-2 -lgobject-2.0 -lORBit-2 -lm -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl  -lselinux   -lacl -lattr -lgpm  -L/home/ziereisen/tools/lib -lluajit-5.1 -Wl,-E -Wl,-rpath,/sw/perl5/lib/5.8.8/x86_64-linux-thread-multi-ld/CORE  -L/usr/local/lib /sw/perl5/lib/5.8.8/x86_64-linux-thread-multi-ld/auto/DynaLoader/DynaLoader.a -L/sw/perl5/lib/5.8.8/x86_64-linux-thread-multi-ld/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc    -lruby -lpthread -ldl -lcrypt -lm  -L/usr/lib64   

但是如果我启动 vim 并尝试命令 py print(1) 或 py3 print(1) 我总是得到消息:

E370: Could not load library libpython2.7.so.1.0
E263: Sorry, this command is disabled, the Python library could not be loaded.

E370: Could not load library libpython3.4m.so.1.0
E263: Sorry, this command is disabled, the Python library could not be loaded.

最佳答案

尝试将 lib 目录添加到 /etc/ld.so.conf 并运行 ldconfig。另一种可能的解决方案可能是将目录添加到 LD_LIBRARY_PATH 环境变量。 – 杰森

关于python - vim: 无法加载库 libpython,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34309101/

相关文章:

python - 父类 "enumerate"如何访问未设置为实例变量的参数?

vim - vim 中术语 "buffer"和 "window"的含义是什么?

vim - Vim 中的 CamelCase 扩展类似于 Intellij Idea?

python - 将文件中的列从高到低排序

python - 为什么 `float` 函数比乘以 1.0 慢?

python - 分配给python中的不连续切片

python - Django csrf token 的作用是什么?

vim - gVim 窗口;如何让 h 和 l 越过换行符

vim - 如何让 vim find 忽略空格?

vim - 升级到 MacOS Sierra 后 tmux + vim 中的剪贴板故障