在Mac上使用Python 2.x支持的Vim编译

时间:2013-11-30 18:25:26

标签: python macos vim

当我运行vim时,我收到此错误:

  

YouCompleteMe不可用:要求使用Python 2.x编译Vim   支撑

即使我用以下内容编译vim:

./configure --with-features=huge \
            --enable-rubyinterp \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-perlinterp \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr

根据these instructions。看起来编译的vim放在/usr/bin/vim中,但我也在/opt/local/bin/vim/usr/bin/vi中尝试了我的vim二进制文件,但是我得到了同样的错误。还有哪些其他选项可以使用Python2.x支持vim编译?

修改

以下是./configure的相关输出:

checking --enable-pythoninterp argument... yes
checking for python2... (cached) /usr/bin/python
checking Python version... (cached) 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... (cached) /System/Library/Frameworks/Python.framework/Versions/2.7
checking Python's execution prefix... (cached) /System/Library/Frameworks/Python.framework/Versions/2.7
(cached) checking Python's configuration directory... (cached) /usr/lib/python2.7/config
(cached) checking if -pthread should be used... no
checking if compile and link flags for Python are sane... no: PYTHON DISABLED

ls /usr/lib/python2.7/config/给出:

Makefile           Setup.local        install-sh         makesetup
Setup              config.c           libpython2.7.a     python.o
Setup.config       config.c.in        libpython2.7.dylib

5 个答案:

答案 0 :(得分:3)

运行后:xcode-select --install

./config输出中的此行已从... no: PYTHON DISABLED更改为 checking if compile and link flags for Python are sane... yes

答案 1 :(得分:3)

我让它与Homebrew vim合作,神奇的命令是:

brew install vim --override-system-vim --HEAD

希望这对你有用,在我偶然发现之前花了一些时间。

答案 2 :(得分:0)

您传递给./configure的内容只是希望拥有该功能。 autoconf 规则仍将测试您的系统,并且只有在所有内容都可用时才包含Python内容。要实际验证Vim是否使用Python支持构建,您需要检查:version的{​​{1}}输出,或+python输出:echo has('python')的输出。如果不是这种情况,请检查1的输出是否与Python相关。您可能缺少一些Python标头/库(但没有完整的./configure输出,很难说明。)

答案 3 :(得分:0)

您只需要安装MacVim:它快速而轻松。

在Mac OS X上手动构建Vim的唯一正当理由是,如果您需要的东西不是MacVim(但在Mac上仍然有意义),例如lua脚本。如果您的需求由MacVim提供,为什么要这么麻烦?

答案 4 :(得分:0)

如果您使用的是MacPorts vim:

sudo port install vim +python27

这解决了我的问题。成立here