Powerline: 将MacOS更新到Mojave,然后vim出现电力线错误

创建于 2018-09-25  ·  34评论  ·  资料来源: powerline/powerline

错误如下:

Error detected while processing /Users/vvqboy/.vimrc:
line    8:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module>
    from powerline.lib.threaded import MultiRunnedThread
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module>
    from powerline.lib.monotonic import monotonic
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module>
    import ctypes
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError
line    9:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
line   10:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module>
    from powerline.lib.threaded import MultiRunnedThread
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module>
    from powerline.lib.monotonic import monotonic
  File "/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module>
    import ctypes
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
Vim: Caught deadly signal SEGV

Vim: Finished.
[1]    7428 segmentation fault  vi .vimrc
cvim macos serror in environment bug

最有用的评论

解!!

1)确定您当前的vim版本。 我的不是用自制软件编译的,但它是默认的系统版本,由Apple重新为Mojave发行版进行了编译(查看日期)。 我认为基于编译日期,该先前声明是准确的,但是如果我错了,请更正我。 运行vim --version ,您应该看到它已经由[email protected]编译。

2)我选择卸载brew'd版本的python @ 2 ,并通过brew安装了python(在编写本文时默认安装3.7.0),并且_did not_链接了它。 只是留在那里。 阅读一些论坛,指出除非安装了Python,否则它不会与brew python一起编译。 @ ZyX-我也许您对此有更多了解?

3)在brew install python ,使用homebrew通过命令brew install vim安装vim。 然后,运行/usr/local/bin/vim --version并确保python3旁边有一个“ +”号。 重新启动您的shell,然后/.vimrc应该显示为: /Library/Python/2.7/site-packages/powerline/powerline/bindings/vim/或您正在查看的任何目录。

...。它应该可以正常工作!

编辑:一些语法,写这没有咖啡。

所有34条评论

vimrc如下:

set rtp+=/Users/vvqboy/Library/Python/2.7/lib/python/site-packages/powerline/bindings/vim

" These lines setup the environment to show graphics and colors correctly.
set nocompatible
set t_Co=256

let g:minBufExplForceSyntaxEnable = 1
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

if ! has('gui_running')
   set ttimeoutlen=10
   augroup FastEscape
      autocmd!
      au InsertEnter * set timeoutlen=0
      au InsertLeave * set timeoutlen=1000
   augroup END
endif

set laststatus=2 " Always display the statusline in all windows
set guifont=Inconsolata\ for\ Powerline:h14
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)

set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

我试着

pip install --upgrade --force-reinstall  --user powerline-status

Collecting powerline-status
  Downloading https://files.pythonhosted.org/packages/9c/30/8bd3c62642778af9ad813a526c6ff7dd2f98144d6580ad6fab94ca389265/powerline-status-2.7.tar.gz (233kB)
    100% |████████████████████████████████| 235kB 69kB/s
Building wheels for collected packages: powerline-status
  Running setup.py bdist_wheel for powerline-status ... done
  Stored in directory: /Users/vvqboy/Library/Caches/pip/wheels/c4/81/6b/bb1f440b9999fcfda2a1ccdf7b57a886acb08ea3e9e794945d
Successfully built powerline-status
Installing collected packages: powerline-status
  Found existing installation: powerline-status 2.6
    Uninstalling powerline-status-2.6:
      Successfully uninstalled powerline-status-2.6
Successfully installed powerline-status-2.7

然后仍然出现错误

Vim: Caught deadly signal SEGV
Error detected while processing /Users/vvqboy/.vimrc:Vim: Finished.

line    8:
Exception MemoryError: MemoryError() in <module 'threading' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.pyc'> ignored
[1]    1788 segmentation fault  vi .vimrc

python --version
Python 2.7.10

嘿,这里有同样的错误。 使用brew尝试了几次修复(认为可能是符号链接问题),但是一切似乎都很好,而且我的pyenv似乎还不错。

这是我要确定的错误(这也是在Moajve更新之后也发生的):

An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Error detected while processing 
...
line  157:
Traceback (most recent call last):
  File "<string>", line 53, in <module>
  File "<string>", line 9, in powerline_troubleshoot
  File "/Users/.../Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/Users/.../Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module>
    from powerline.lib.threaded import MultiRunnedThread
  File "/Users/.../Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module>
    from powerline.lib.monotonic import monotonic
  File "/Users/.../Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module>
    import ctypes
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError

有趣的是,将路径指向_actual_ powerline.vim文件将很好地加载vim并且不会引发任何错误,但也不会加载电力线。

/Library/Python/2.7/site-packages/powerline/powerline/bindings/vim/plugins/powerline.vim

Vim高兴地放弃了电源线而没有加载电源线...此外,我的tmux conf加载电源线也很好,所以我认为这是vim电源线特有的问题。 我会做一些调查,然后回覆您。

编辑:切换到python的系统版本并运行交互式外壳程序使我可以运行
from powerline.vim import VimPowerLine没有任何麻烦。

无论出于何种原因,我都无法注释掉CTYPES行(某些权限错误,将在以后进行进一步调查),但是我无法跟踪实际完成内存分配的源文件。 有谁知道该文件在哪里,或者这是否是正确的处理方式?

Python版本的Vim是否与实际使用的Python版本匹配? 导入ctypes时,先使用MemoryError和SEGV表示Python安装问题,而不是电力线问题。 如果禁用电源线并在vim中执行:python import ctypes ,则应该遇到相同的问题(至少是MemoryError,尽管我不确定它的实际含义:也许,内存分配器返回NULL?)。

宾果游戏,那没有用。 但是,在MacOS Mojave更新之前,它运行得非常好。

更新到莫哈韦沙漠后出现错误+1

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module>
    from powerline.lib.threaded import MultiRunnedThread
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module>
    from powerline.lib.monotonic import monotonic
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module>
    import ctypes
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Error detected while processing /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/plugin/powerline.vim:
line  157:
Traceback (most recent call last):
  File "<string>", line 53, in <module>
  File "<string>", line 9, in powerline_troubleshoot
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module>
    from powerline.lib.threaded import MultiRunnedThread
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module>
    from powerline.lib.monotonic import monotonic
  File "/Users/zzs/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module>
    import ctypes
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module>
    _reset_cache()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache
    CFUNCTYPE(c_int)(lambda: None)
MemoryError
Press ENTER or type command to continue

Python版本的Vim是否与实际使用的Python版本匹配? 导入ctypes时,先使用MemoryError和SEGV表示Python安装问题,而不是电力线问题。 如果禁用电源线并在vim中执行:python import ctypes ,则应该遇到相同的问题(至少是MemoryError,尽管我不确定它的实际含义:也许,内存分配器返回NULL?)。

因此,就在升级之前,它运行良好。 我的zsh和tmux设置也可以使用其他绑定正常工作。

在vim中运行命令: :python import ctypes时,我得到了与上面所示相同的错误(CTYPE错误)。 我想知道苹果在出厂的Apple-Python版本中发生了什么变化,或者实际上是否发生了变化。 我会在今晚晚些时候尝试并返回。

Zsh和tmux在单独的进程中使用Python解释器(除非您将zsh与libzpython一起使用,但是没有tmux等效项)。 Vim是通过dlopen将Python作为动态库加载,或者只是通过它链接而变得更加脆弱,并且如果您更改了Python版本,则需要使用新的Python重新编译Vim,否则可能会遇到问题。 我不确定版本的差异如何导致ctypes导入出现故障(通常您根本无法运行:python ,否则有时可能会崩溃),但这是一种可能的解释。

另一个是系统版本和自制Python版本之间的区别。 我没有Mac,也不能说应该由哪个Vim加载这两个Vim,以及它如何完成这项功能,但这是Mac(app(vim,etc))+ Python设置问题的另一个常见解释,可能会导致导入错误。

@ ZyX-我知道了。 您是否有附带的文档来描述该过程? 我不知道那是怎么回事。

让我用系统版本重新编译vim,看看会发生什么!

解!!

1)确定您当前的vim版本。 我的不是用自制软件编译的,但它是默认的系统版本,由Apple重新为Mojave发行版进行了编译(查看日期)。 我认为基于编译日期,该先前声明是准确的,但是如果我错了,请更正我。 运行vim --version ,您应该看到它已经由[email protected]编译。

2)我选择卸载brew'd版本的python @ 2 ,并通过brew安装了python(在编写本文时默认安装3.7.0),并且_did not_链接了它。 只是留在那里。 阅读一些论坛,指出除非安装了Python,否则它不会与brew python一起编译。 @ ZyX-我也许您对此有更多了解?

3)在brew install python ,使用homebrew通过命令brew install vim安装vim。 然后,运行/usr/local/bin/vim --version并确保python3旁边有一个“ +”号。 重新启动您的shell,然后/.vimrc应该显示为: /Library/Python/2.7/site-packages/powerline/powerline/bindings/vim/或您正在查看的任何目录。

...。它应该可以正常工作!

编辑:一些语法,写这没有咖啡。

升级到Mojave时出现相同的错误。
line 63: Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/xxx/Library/Python/2.7/lib/python/site-packages/powerline/__init__.py", line 11, in <module> from powerline.lib.config import ConfigLoader File "/Users/xxx/Library/Python/2.7/lib/python/site-packages/powerline/lib/config.py", line 11, in <module> from powerline.lib.threaded import MultiRunnedThread File "/Users/xxxx/Library/Python/2.7/lib/python/site-packages/powerline/lib/threaded.py", line 7, in <module> from powerline.lib.monotonic import monotonic File "/Users/xxx/Library/Python/2.7/lib/python/site-packages/powerline/lib/monotonic.py", line 19, in <module> import ctypes File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 555, in <module> _reset_cache() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 279, in _reset_cache CFUNCTYPE(c_int)(lambda: None) MemoryError line 64: Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'powerline_setup' is not defined line 65: Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'powerline_setup' is not defined
回滚到系统默认的python之后,我仍然遇到相同的错误。

@zhongruizhi你尝试了我上面的建议吗? 我发布了解决方案,并为我解决了问题!

@anirrudh
谢谢,但看来您的解决方案不太适合我的情况。 我没有使用brew,而是使用系统的默认python(2.7.10)和vim。(+ python / dyn -python3)。

@anirrudh对我来说真的很有效,一个很好的解决方案,非常感谢

@zhongruizhi所以我以前也有苹果公司提供的标准vim版本,但是对于电力线来说似乎是不可行的,唯一的解决方法似乎是通过brew安装vim;对于python版本,我在我的地址中提到了这一点。上面的帖子,但您需要确保+ python3是一个东西,而不是+ python / dyn,这正是我的苹果公司提供的vim所具有的东西!

@anirrudh谢谢您弄清楚细节。 而且有效。

我发现了原因和解决方案,我认为它更为详细:
文件中_reset_cache()函数处的CFUNCTYPE:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py
获取内存错误。
然后我跳到该文件,找到了这样的代码:

265 def _reset_cache():
266     _pointer_type_cache.clear()
267     _c_functype_cache.clear()
268     if _os.name in ("nt", "ce"):
269         _win_functype_cache.clear()
270     # _SimpleCData.c_wchar_p_from_param
271     POINTER(c_wchar).from_param = c_wchar_p.from_param
272     # _SimpleCData.c_char_p_from_param
273     POINTER(c_char).from_param = c_char_p.from_param
274     _pointer_type_cache[None] = c_void_p
275     # XXX for whatever reasons, creating the first instance of a callback
276     # function is needed for the unittests on Win64 to succeed.  This MAY
277     # be a compiler bug, since the problem occurs only when _ctypes is
278     # compiled with the MS SDK compiler.  Or an uninitialized variable?
279     CFUNCTYPE(c_int)(lambda: None)

如您所见,Win64上的unittest出于任何原因在第279行添加了CFUNCTYPE函数。 对于mac用户,此行无用,并导致macOS出现内存错误。 所以我注释掉了第279行,然后重新运行vim,电源线没有错误。

更多细节:
__init__.py文件是系统只读文件,您需要在mac恢复模式下运行命令csrutil disable (启动时按Command + R)以禁用系统完整性保护。 重新启动后,您可以使用root权限编辑此文件。

brew install vim --with-lua --with-override-system-vi
然后重新启动shell,修复

https://github.com/Valloric/YouCompleteMe/issues/3165#issuecomment -425616700

谢谢@ Joshua-Chang

对我有用

谢谢@ Joshua-Chang
vim可以,但是vi仍然错误
`Vim:收到致命信号SEGV
处理功能时检测到错误70_PollServerReady [7] ..70_ Pyeval:Vim :完成。

第4行:
异常MemoryError:中的MemoryError()被忽略
细分错误:11`

vim可以,但是vi仍然错误

也许那里有更好的分辨率,但是我通过在外壳rc文件中添加alias vi="vim"来解决该问题

当我使用commad git commit --amend时, @ whenever77也有相同的问题。

@kyriejoshua

试试@ Joshua-Chang的建议,它对我有用。

试试@ Joshua-Chang的建议,它对我有用。

我试过了。
当我直接使用vim时它可以工作,但是当我运行命令git commit --amend或尝试修复命令行中的冲突时仍然是错误的。

最后,我通过阅读本文解决了这个问题。 @ whenever77
https://ltaoo.github.io/2018/10/22/%E6%9B%B4%E6%96%B0%20macOS%20Mojave%20%E5%90%8E%20vim%20%E6%89%93 %E4%B8%8D%E5%BC%80 /

@kyriejoshua介意分享解决方案?

这是我的解决方案。 @josephtyler

cd ~/.vim/bundle/YouCompleteMe
git pull
git submodule update --init --recursive.
python install.py

然后重新启动shell,修复

对于YCM用户,请使用YCM联系人

我们在这里跟踪与系统Vim类似的问题: https :

剧透警报:我认为这是莫哈韦沙漠而不是YCM。

对我来说,这个问题开始出现在Mojave安装了“关键更新”之后(例如,我在Mojave上使用过vim / powerline可以正常工作了很长时间)。 原来这只是使用错误的vim情况(例如/usr/bin/vim ,Apple的内置vim),而不是我的/usr/local/bin/vim vim。 这只是修复我的PATH一种情况; 更新大概重新排序了。

我刚开始使用全新安装的Mojave的Mac,但遇到了这个问题,应该注意的是我正在使用python3.7。

我通过执行以下操作解决了该问题:

brew install vim
echo "alias vim=/usr/local/Cellar/vim/<VIM_VERSION>/bin/vim" >> ~/.bash_profile

只需将VIM_VERSION替换为第一行中安装的brew的vim版本即可。

可以添加另一个确认,该确认与macOS Mojave更新有关。 我将不得不与另一台尚未更新的机器进行比较,以查看哪些系统库发生了变化。 我敢肯定,这是在默认的python 2.7(.10)安装中已更改的内容,或具有相关库的内容。

如果从bash到zsh都出现了同样的问题,对我来说解决的问题是导出PATHexport PATH=$HOME/bin:/usr/local/bin:$PATH

我已经有python 3.7.3,vim(该版本包含在[email protected]编译的macvim中),并且已经有Mojave。 仅过渡到zsh。

因此,我不得不将头撞到墙上,试图弄清楚为什么我被迫将工作笔记本电脑升级到Mojave后的第二天对我来说不起作用。 我按照上面的指南进行操作,并使电源线再次在vim中工作,但是对于我的生命,当我尝试git commit时,它无法正常工作。

我仔细检查了.zshrc ,将编辑器设置为vim 。 然后我alias vi=vim ,仍然没有骰子。

然后在重新安装了powerline和vim大约一百次之后,我在错误消息中注意到了它(此错误消息是在重新启动终端窗口并且不启动tmux或其他任何东西之后的小得多的错误消息:

Vim: Caught deadly signal SEGV
Vim: Finished.
error: /usr/bin/vim died of signal 11
error: There was a problem with the editor '/usr/bin/vim'.
Please supply the message using either -m or -F option.

就在这里: /usr/bin/vim

因此,我仔细检查了一下,发现我的.gitconfig了一行:

[core]
editor = /usr/bin/vim

这样就变成了editor = vim

TL; DR :如果您仍然在安装git commit vim时遇到问题,请仔细检查.gitconfig是否未指向系统vim。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

nfarrar picture nfarrar  ·  11评论

pmalek picture pmalek  ·  11评论

atrauzzi picture atrauzzi  ·  21评论

starlays picture starlays  ·  26评论

djbender picture djbender  ·  24评论