这是在 OS X 10.8.4 上。 当尝试在 vim 中使用 powerline 与 homebrew python 2.7.5 链接时,以下回溯结果:
goldfish:~ goldfish$ brew link python
Linking /usr/local/Cellar/python/2.7.5... 34 symlinks created
goldfish:~ goldfish$ vim
Error detected while processing /Users/goldfish/.vimrc:
line 70:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/goldfish/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 9, in <module>
from powerline.lib.config import ConfigLoader
File "/Users/goldfish/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 3, in <module>
from powerline.lib.threaded import MultiRunnedThread
File "/Users/goldfish/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 5, in <module>
from powerline.lib.monotonic import monotonic
File "/Users/goldfish/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 22, in <module>
import ctypes
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
ImportError: dlopen(/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_ctypes.so
line 71:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
line 72:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
Press ENTER or type command to continue
我的.vimrc
的相关部分:
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
使用系统 python ( brew unlink python
) 有效。
不幸的是,我不知道如何,但重新启动 iTerm 神奇地解决了这个问题。
重新启动 iTerm +1 ... 😢
当您安装新版本的 python 时,可能会出现此问题。 在这些情况下,您可能需要运行hash -r python
来告诉 bash 将缓存位置重置为 python 可执行文件。
最有用的评论
不幸的是,我不知道如何,但重新启动 iTerm 神奇地解决了这个问题。