vim编译与错误的python版本(而不是与所需的版本工作) [英] vim compiles with wrong python version (and not working with needed version)
问题描述
简要说明:
使用优先的python版本编译vim时遇到问题。
当我使用 -enable-pythoninterp
它与系统OSX python版本编译。
当我使用 - enable-pythoninterp = dynamic
I在尝试时,在vim中得到一个错误:py import sys
这里是我正在做的更多细节: / h3>
%git clone https://github.com/b4winckler/macvim.git
%cd macvim
%./configure --enable-pythoninterp \
--with-python-config-dir = / usr / local / lib / python2.7 / config<对结果没有影响
...
检查python ... / usr / local / bin / python
检查Python版本... 2.7
检查Python是否为1.4或更好... yep
检查Python的安装前缀... / usr / local
检查Python的执行前缀... / usr / local
检查Python的配置目录... / usr / local / lib / python2.7 / config
...
%make
...
** BUILD SUCCEEDED **
%open src / MacVim / build / Release /MacVim.app
%git clone https://github.com/b4winckler/macvim.git
%cd macvim
%./configure --enable-pythoninterp \
--with-python-config-dir = / usr / local / lib / python2.7 / config<对结果没有影响
...
检查python ... / usr / local / bin / python
检查Python版本... 2.7
检查Python是否为1.4或更好... yep
检查Python的安装前缀... / usr / local
检查Python的执行前缀... / usr / local
检查Python的配置目录... / usr / local / lib / python2.7 / config
...
%make
...
** BUILD SUCCEEDED **
%open src / MacVim / build / Release /MacVim.app
在打开的MacVim I类型中:
:py import sys; print(sys.version,sys.executable)
('2.6.1(r261:67515,2010年6月24日,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
我一整天都在搜索解决方案。我找到了。这是 =动态属性(但此解决方案没有解释)。
之后,我尝试使用动态python重新编译vim:
%./configure --enable-pythoninterp = dynamic
...输出相同的...
%make
%打开src / MacVim / build / Release / MacVim。 app
在打开的MacVim中:
:py import sys
出现错误:
E370:无法加载库libpython2.7.a
E263:对不起,此命令被禁用,无法加载Python库。
我的OSX版本是10.6.8。 >
默认python版本是2.7。%that python
/ usr / local / bin / python
任何人都可以解释python在编译期间如何集成到vim中?
和如何使用libpython2修复错误。 7.a?
更新:在问题。所以我不能测试新的答案。
解决方案我有同样的问题。我从源编译了 Macvim 并尝试使用来自macports的python版本2.7:
/ opt / local / bin / python
没有找到一些模块,例如os模块。原因是PYTHONPATH变量 inside 在macvim中是错误的!
要测试,打开macvim并键入:
:python print sys.path
我有以下路径(注意结尾,这是废话):
...
/ opt / local / Library / Frameworks / Python.framework / Versions / 2.7 / lib / python2.5 /'
...
我认为原因是在链接器标志-framework Python。这个错误,即系统 python框架。如果我更改
src / auto / configure
脚本中的行:if testx $ MACOSX=xyes&& $ {vi_cv_path_python} -c \
import sys; sys.exit($ {vi_cv_var_python_version}< 2.3); then
vi_cv_path_python_plibs = - framework Python
到
如果测试x $ MACOSX=xyes&& $ {vi_cv_path_python} -c \
import sys; sys.exit($ {vi_cv_var_python_version}< 2.3); then
vi_cv_path_python_plibs = - F / opt / local / Library / Frameworks -framework Python
再次运行configure,make clean后,
Macvim按预期编译和工作。 -F标志告诉链接器在哪个目录中找到以下框架。 Macports在此目录中安装Python.framework,YMMV。In brief:
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
Here is what I was doing in more detail:
% 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
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')
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).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
In opened MacVim:
:py import sys
And here comes an error:
E370: Could not load library libpython2.7.a E263: Sorry, this command is disabled, the Python library could not be loaded.
My OSX version is 10.6.8.
Default python version is 2.7.% which python /usr/local/bin/python
Can anybody explain how python is integrating into vim during the compilation?
And how to fix the error with 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.
解决方案I had the same problem. I compiled Macvim from source and tried to use the python version 2.7 from macports in:
/opt/local/bin/python
Some modules were not found, for example the os module. The reason for this was that the PYTHONPATH variable inside macvim is wrong!
To test, open macvim and type:
:python print sys.path
I got the following paths (note the ending, which is nonsense):
... /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.5/' ...
I presume the reason is in the linker flag "-framework Python". This picks up the wrong, i.e. the system python framework. If I change the line in the
src/auto/configure
script from:if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \ "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then vi_cv_path_python_plibs="-framework Python"
to
if test "x$MACOSX" = "xyes" && ${vi_cv_path_python} -c \ "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then vi_cv_path_python_plibs="-F/opt/local/Library/Frameworks -framework Python"
Running configure again, after make clean, Macvim compiles and works as expected. The -F flag tells the linker in which directory to find the following framework. Macports installs the Python.framework in this directory, YMMV.
这篇关于vim编译与错误的python版本(而不是与所需的版本工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!