需要使用已编译 +python 功能的 Vim

5
当我在Python文件中输入“raw”,并按下<C-x><C-o>时,我收到错误提示:“需要使用已编译+python的vim”。但是,根据命令:version的结果,在python前面有一个+而不是-。我该怎么做来解决这个问题?
+arabic          +cursorbind      -footer          +mksession       +path_extra      +startuptime     +visual
+autocmd         +cursorshape     +fork()          +modify_fname    -perl            +statusline      +visualextra
-balloon_eval    +dialog_con      +gettext         +mouse           +persistent_undo -sun_workshop    +viminfo
-browse          +diff            -hangul_input    -mouseshape      +postscript      +syntax          +vreplace
++builtin_terms  +digraphs        +iconv           +mouse_dec       +printer         +tag_binary      +wildignore
+byte_offset     -dnd             +insert_expand   -mouse_gpm       +profile         +tag_old_static  +wildmenu
+cindent         -ebcdic          +jumplist        -mouse_jsbterm   +python/dyn      -tag_any_white   +windows
+clientserver    +emacs_tags      +keymap          +mouse_netterm   +python3/dyn     -tcl             +writebackup
+clipboard       +eval            +langmap         +mouse_sgr       +quickfix        +terminfo        +X11
+cmdline_compl   +ex_extra        +libcall         -mouse_sysmouse  +reltime         +termresponse    +xfontset
+cmdline_hist    +extra_search    +linebreak       +mouse_urxvt     +rightleft       +textobjects     -xim
+cmdline_info    +farsi           +lispindent      +mouse_xterm     -ruby            +title           -xsmp
+comments        +file_in_path    +listcmds        +multi_byte      +scrollbind      -toolbar         +xterm_clipboard
+conceal         +find_in_path    +localmap        +multi_lang      +signs           +user_commands   -xterm_save
+cryptv          +float           -lua             -mzscheme        +smartindent     +vertsplit
+cscope          +folding         +menu            +netbeans_intg   -sniff           +virtualedit

谢谢


我有同样的问题,这里的被接受的答案解决了我的问题。在通过从源代码构建安装vim期间,您需要使用一些参数执行配置脚本,所述答案说--with-python3-config-dir=参数已过时,不应使用。 - ahmadkarimi12
2个回答

3

被标记为*/dyn的功能可能可用,也可能不可用。对于这些功能的支持并不是内置的,而是依赖于专用共享对象的存在。

对于某些功能,仅在相关库可以动态加载时才添加了"/dyn"。

要检查您的vim是否可以使用动态特性(如python),请执行以下操作:

:echo has('python')

它将打印0(假)或1(真)。
另请参见python-dynamic
更新:
如果你从源代码安装了vim,你需要重新构建它。使用--enable-pythoninterp--with-python-config-dir选项。还要确保你已经安装了python开发头文件和库(devel包)。

感谢您的答复。 在我的vim中执行:echo has('python')后,我收到以下错误: E448: 无法加载库函数 _PyArg_Parse_SizeT E263: 抱歉,此命令已禁用,无法加载Python库。 - Liangmin Li
Python-dynamic似乎在Windows上使用,但我在Centos 7中运行vim,并通过源代码安装了它。 - Liangmin Li
3
您可能会看到:echo has('python')= 0,但是 :echo has('python3')= 1。这句话的意思是,您的系统支持Python3,但不支持Python。 - Alex Kroll
1
这对我来说是个问题,(has('python') = 0, has('python3')=1) 但是当我在一个Python文件上启动nvim时,如何停止错误显示呢? - Michael Draper
@MichaelDraper你能解决这个问题吗? - theSekyi

0

对于Ubuntu 16.04,在安装插件后,执行以下步骤以解决问题:

sudo apt-get install vim-gnome-py2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接