使用Python支持编译Vim7.4源代码失败。

7

我已经下载了vim7.4的源代码,并决定将vim升级到7.4版本。 然而,我无法为其添加python支持:

./configure  --enable-pythoninterp  --enable-rubyinterp --enable-gui=no --without-x --enable-cscope --enable-multibyte --prefix=/usr

在查看src/auto/config.log时,我发现:

configure:5592: checking Python's configuration directory
configure:5614: result:·
configure:5620: result: can't find it!

安装的Python信息:

dpkg-query -l python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                             Version                          Description
+++-================================-================================-   ================================================================================
ii  python                           2.7.3-0ubuntu2.2                 interactive high-level object-oriented language (default version)

在src目录中调用make之后:
./vim --version | grep python
+cryptv          +linebreak       -python          +viminfo
+cscope          +lispindent      -python3         +vreplace

似乎是因为vim无法找到Python的配置目录所致。如何解决?
提前感谢您的见解。

可能是使用Python支持编译Vim的重复问题。 - Ciro Santilli OurBigBook.com
似乎缺少 python-dev - KunMing Xie
4个回答

17

确保已安装Python开发包(我想是python-devel或python-dev)。您可以通过向./configure传递类似以下内容来指定Python配置目录:

请注意检查是否安装了Python开发包(python-devel或python-dev)。 您可以通过向./configure传递类似以下内容来指定Python配置目录:

--with-python-config-dir=/usr/lib64/python2.7/config

查找配置目录(首先您可能需要执行updatedb):

locate python | grep '/config$'

我已经尝试将 --with-python-config-dir=/usr/lib/python2.7/config 加入到 ./configuration 命令标志中。在 make 过程中遇到了新问题: -I/usr/include/python2.7 -DPYTHON_HOME='"/usr"' -pthread -fPIE -o objects/if_python.o if_python.c if_python.c:58:20: 致命错误:Python.h:没有那个文件或目录 编译终止。 make: *** [objects/if_python.o] 错误 1 - FaceBro
~  locate python | grep '/config$' /usr/lib/python2.7/config - FaceBro
你有安装Python开发包吗?而且locate Python.h命令的输出是什么? - perreal
在 Mac OS X 上,我使用 homebrew 安装了 python3。我使用命令 locate python3 | grep '/config$',但终端没有输出任何内容。接下来该怎么办?@perreal - soarinblue
我运行了以下命令:rm src/auto/config.cache && ./configure --enable-pythoninterp=yes --prefix=/data/exec/vim --with-python-command=/data/exec/python2.7/bin/python2.7,请不要忘记执行 rm src/auto/config.cache。如果你在使用 Python 2.6 编译前没有删除它,你将会收到“版本过旧”的提示。 - Tony_Wang
您可能需要先安装python-devel。在CentOS上,只需运行sudo yum install -y python-devel即可。 - Michael Meepo

10

从您的错误信息来看,您没有安装python-dev

sudo apt-get install python-dev

这应该可以解决你的问题。


+1,这将安装Python源代码所需的头文件,以便Vim使用。 - Brian Neal

3

请确保您已安装了Python的开发包,并指向适当的config目录。

例如:./configure --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config


0

其他答案给出了正确的解决方案,即添加cli开关

--with-python-config-dir=/usr/lib/python2.7/config

另外,运行它可能是个好主意。

make clean distclean

对我来说,如果不清理现有的构建,它就无法获取新的配置


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