vim 使用错误的 python 版本编译(并且不使用所需的版本) [英] vim compiles with wrong python version (and not working with needed version)

查看:25
本文介绍了vim 使用错误的 python 版本编译(并且不使用所需的版本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用首选 python 版本编译 vim 时遇到问题.
当我使用 --enable-pythoninterp 时,它会与系统 OSX python 版本一起编译.
当我使用 --enable-pythoninterp=dynamic 时,我在尝试 :py import sys

I have a problem with compiling vim with preferred python version.
When I use --enable-pythoninterp it compiles with system OSX python version.
When I use --enable-pythoninterp=dynamic I get an error in vim while trying :py import sys

% git clone https://github.com/b4winckler/macvim.git
% cd macvim
% ./configure --enable-pythoninterp 
     --with-python-config-dir=/usr/local/lib/python2.7/config <- this option has no affects on result
...
checking for python... /usr/local/bin/python
checking Python version... 2.7
checking Python is 1.4 or better... yep
checking Python's install prefix... /usr/local
checking Python's execution prefix... /usr/local
checking Python's configuration directory... /usr/local/lib/python2.7/config
...
% make
...
** BUILD SUCCEEDED **
% open src/MacVim/build/Release/MacVim.app

在打开的 MacVim 中输入:

In the opened MacVim I type:

:py import sys; print (sys.version, sys.executable)
('2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
  [GCC 4.2.1 (Apple Inc. build 5646)]',
 '/usr/bin/python')

为什么是 2.6.1?
为什么是 /usr/bin/python?
我的默认 python 是 2.7!它位于 /usr/local/bin/python

我整天都在寻找解决方案.我找到了.它是 =dynamic 属性(但这个解决方案没有解释).

Why 2.6.1?
Why /usr/bin/python?
My default python is 2.7! And it lives at /usr/local/bin/python

I was searching for solution all day. And I found it. It is =dynamic attribute (but this solution had not explanation).

之后我尝试用动态python重新编译vim:

After that I tried to recompile vim with dynamic python:

% ./configure --enable-pythoninterp=dynamic
... output the same ...
% make
% open src/MacVim/build/Release/MacVim.app

在打开的 MacVim 中:

In opened MacVim:

:py import sys

这里出现了一个错误:

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

<小时>

我的 OSX 版本是 10.6.8.
默认 python 版本是 2.7.


My OSX version is 10.6.8.
Default python version is 2.7.

% which python
/usr/local/bin/python

谁能解释一下python在编译过程中是如何集成到vim中的?
以及如何修复 libpython2.7.a 的错误?

更新:我不再拥有问题中描述的环境.所以我无法测试新的答案.但是人类的剩余部分会感谢您的帮助.

update: I no longer have the environment described at the question. So I couldn't test new answers. But remaining part of mankind will appreciate your help.

推荐答案

我的解决方案是删除配置缓存文件,该文件是从我使用 OSX 附带的 python 的先前构建中创建的.

My solution was to delete the configure cache file which was created from a previous built where I used the python which came with OSX.

然后我用自制软件安装了一个新的 python 版本,但无法让 .configure 使用新的 python 版本,即使我更新了我的 PATH 变量并且哪个 python 显示了正确的 python 版本.

Then I installed a new python version with homebrew and couldn't get .configure to take the new python version, even though I updated my PATH variable and which python showed the right python version.

删除缓存文件并再次运行配置解决了我的问题.

Deleting the cache file and running configure again solved my problem.

rm src/auto/config.cache
./configure --enable-pythoninterp

也许它可以帮助任何人.

Maybe it helps anybody.

这篇关于vim 使用错误的 python 版本编译(并且不使用所需的版本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆