homebrew macvim与python2.7.3支持无法正常工作

时间:2012-06-21 23:45:24

标签: python vim macvim homebrew

我用自制软件安装了macvim,支持python。我的咒语如下:

brew install macvim --override-system-vim

现在,当我打开python文件时,如果我尝试导入任何内容,我会收到一系列错误。例如如果我import re,我会看到ImportError: no module name re

我第一次在安装后打开macvim时,在我打开macvim的终端中得到'import site' failed; use -v for traceback。这是在运行我的第一个python命令之后。

这是什么意思,我该如何解决?

3 个答案:

答案 0 :(得分:23)

我使用了一个快速的黑客,你暂时将系统python指向你喜欢的python:

cd /System/Library/Frameworks/Python.framework/Versions
sudo mv Current Current-sys
sudo mv 2.7 2.7-sys
sudo ln -s /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7 Current
sudo ln -s /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7 2.7

brew rm macvim # optionall, only if you had it installed previously  
brew install macvim --override-system-vim

sudo mv Current-sys Current
sudo mv 2.7-sys 2.7

答案 1 :(得分:1)

我的猜测是,您应该将自制软件安装文件夹添加到.bash_profile中,如下所示:

export PATH=/usr/local/bin:/usr/local/sbin:usr/local/Cellar/python/2.7.3/bin:$PATH

之后写入shell“source .bash_profile”,以便重新加载。另请检查

的输出
which python 

确保使用自制的python

答案 2 :(得分:0)

我最终放弃了自制选项并使用此处建议的答案:

vim compiles with wrong python version (and not working with needed version)

很遗憾看起来这不能通过brew来完成。看起来有人需要修补macvim发布本身。