vim - 配置python3支持但仍在版本信息中显示-python3

时间:2014-10-18 08:39:44

标签: python-3.x vim

我正在尝试使用python3支持在Ubuntu 12.04上构建vim,因为默认安装只支持python2。我从https://vim.googlecode.com/hg/中提取源代码并进行如下配置:

./configure --disable-pythoninterp --enable-python3interp --with-features huge

我也试过了--enable-pythoninterp选项。

当我在这个安装上运行vim --version时,我仍然像这样得到-python3:

$ ./src/vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 18 2014 09:32:02)
Included patches: 1-481
Compiled by brendan@brendan-laptop
Normal version with GTK2 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          +viminfo
-cscope          +lispindent      -python3         +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: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/harfbuzz     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux -lacl -lattr -lgpm -ldl    

从上面可以看出,python3支持不包含在二进制文件中。

我也安装了python3-dev,虽然我确定是否需要。

sudo apt-get install python3-dev

非常感谢任何帮助!

由于

2 个答案:

答案 0 :(得分:3)

您还需要使用

指定python配置目录
--with-python3-config-dir=

运行configure时,因为配置似乎无法自动查找目录。


使configure自动查找python3-config-dir的另一种方法是确保python指向python 3可执行文件而不是python 2可执行文件(大多数系统默认为)


我还建议使用--enable-fail-if-missing运行configure,以便配置脚本失败,而不是静静地警告它没有找到python3配置目录或可执行文件。

答案 1 :(得分:3)

从源

构建Vim
  • 首先,安装所有必备库,包括Mercurial。对于像Ubuntu这样的类似Debian的Linux发行版,它将是以下内容:

bash sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \ libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \ ruby-dev mercurial 对于Fedora 20,将是以下内容:

bash sudo yum install -y ruby ruby-devel lua lua-devel luajit \ luajit-devel ctags mercurial python python-devel \ python3 python3-devel tcl-devel \ perl perl-devel perl-ExtUtils-ParseXS \ perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \ perl-ExtUtils-Embed

  • 如果已经使用,请删除vim。

bash sudo apt-get remove vim vim-runtime gvim vim-tiny vim-common vim-gui-common

  • 安装完所有内容后,轻松获取源代码。如果你没有使用vim 7.4,请确保在下面正确设置VIMRUNTIMEDIR变量(例如,使用vim 7.4a,使用/ usr / share / vim / vim74a):

bash cd ~ hg clone https://code.google.com/p/vim/ cd vim ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp \ --enable-python3interp vi_cv_path_python3=/usr/bin/python3.4 \ --with-python-config-dir=/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu \ --enable-perlinterp \ --enable-luainterp \ --enable-gui=gtk2 --enable-cscope --prefix=/usr make VIMRUNTIMEDIR=/usr/share/vim/vim74 sudo apt-get install checkinstall sudo checkinstall

  • 使用update-alternatives
  • 将vim设置为默认编辑器

bash sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1 sudo update-alternatives --set editor /usr/bin/vim sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1 sudo update-alternatives --set vi /usr/bin/vim

完成