vim可以用来编译python吗_vim编译与错误的python版本(而不是与所需的版本工作)...

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

...

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值