Powerline: Update MacOS to Mojave, then vim get error with powerline

Created on 25 Sep 2018  ·  34Comments  ·  Source: powerline/powerline

error as follow:

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

Most helpful comment

SOLUTION!!

1) Figure out your current vim version. Mine was _not_ compiled with homebrew, but was the default system version, which was recompiled by Apple for the Mojave release (looking at the date). I think the prior statement it accurate, based on the compile date, but correct me if I am wrong. Run vim --version and you should see that it has been compiled by [email protected].

2) I chose to uninstall the brew'd version of python@2, and installed python via brew (it installs 3.7.0 by default at the time of writing), and _did not_ link it. Just left it there. Read some forum stating that it doesn't compile with brew python unless it is installed. @ZyX-I maybe you know more about this?

3) After brew install python, use homebrew to install vim using command brew install vim. Then, run /usr/local/bin/vim --version and make sure the python3 has a '+' sign next to it. Restart your shell, and then the /.vimrc should read: /Library/Python/2.7/site-packages/powerline/powerline/bindings/vim/ or whatever dir you are looking at.

....and it should be working!

Edit: Some grammar, wrote this without coffee.

All 34 comments

vimrc as follow:

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

I try to

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

then still get error

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

Hey, same error here. Tried a couple fixes using brew (thought it may be a sym link issue), but all seems to be well there, and my pyenv seems fine.

Here is the err I get to be doubly sure (and this happened after Moajve update as well for me):

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

Interestingly, pointing the path to the _actual_ powerline.vim file will load vim fine and won't throw any errors, but does not load the powerline either.

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

Vim happily chugs away WITHOUT loading powerline... Additionally, my tmux conf loads powerline just fine, so I think this is an issue specific to vim-powerline. I'll do some investigation and get back to you.

Edit: Switching to the system version of python and running an interactive shell allowed me to run
from powerline.vim import VimPowerLine without any hassle.

For whatever reason, I am not able to comment out the CTYPES line (some permissions error, will investigate further later), but I am not able to trace the source file where the memory allocation is actually being done. Does anyone know where this file exists, or if that is even the right way to proceed?

Does Python version Vim was compiled with match Python version Vim is actually using? MemoryError and then SEGV while importing ctypes indicates problems with Python installation, not powerline problems. You should get the same problem (at least, MemoryError, though I am unsure what it actually means: perhaps, memory allocator returning NULL?) if you disable powerline and do :python import ctypes in vim.

Bingo, that did not work. However, it was working absolutely fine before the MacOS Mojave Update.

Error +1 after updated to mojave

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

Does Python version Vim was compiled with match Python version Vim is actually using? MemoryError and then SEGV while importing ctypes indicates problems with Python installation, not powerline problems. You should get the same problem (at least, MemoryError, though I am unsure what it actually means: perhaps, memory allocator returning NULL?) if you disable powerline and do :python import ctypes in vim.

So it was working fine _just before_ the upgrade. My zsh and tmux setup are working fine using the other bindings as well.

When running the command: :python import ctypes in vim, I get the same error (the CTYPE error) as shown above. I wonder what Apple changed in the shipped version of Apple-Python, or really, if they changed anything. I'll try a little later tonight and revert back.

Zsh and tmux use Python interpreter in a separate process (unless you are using zsh with libzpython, but there is no tmux equivalent). Vim is either loading Python as a dynamic library via dlopen or just links with it which is more fragile, and should you ever change Python version you need to recompile Vim with the new one or risk running into problems. I am not sure how differences in versions may cause ctypes import to malfunction that late (normally you would not get :python running at all, or it may sometimes crash), but it is one possible explanation.

Another one is the difference between system and homebrew Python version. I have no Mac and can’t say which one Vim is supposed to load of the two and how exactly it does the feat, but this is another common explanation of problems with (app(vim, etc))+Python setup on Mac, and it may cause various kinds of errors on import.

@ZyX-I oooo got it. Do you have a doc off-hand describing the process? I had no idea that was how it worked.

Let me recompile vim with the system version and see what happens!

SOLUTION!!

1) Figure out your current vim version. Mine was _not_ compiled with homebrew, but was the default system version, which was recompiled by Apple for the Mojave release (looking at the date). I think the prior statement it accurate, based on the compile date, but correct me if I am wrong. Run vim --version and you should see that it has been compiled by [email protected].

2) I chose to uninstall the brew'd version of python@2, and installed python via brew (it installs 3.7.0 by default at the time of writing), and _did not_ link it. Just left it there. Read some forum stating that it doesn't compile with brew python unless it is installed. @ZyX-I maybe you know more about this?

3) After brew install python, use homebrew to install vim using command brew install vim. Then, run /usr/local/bin/vim --version and make sure the python3 has a '+' sign next to it. Restart your shell, and then the /.vimrc should read: /Library/Python/2.7/site-packages/powerline/powerline/bindings/vim/ or whatever dir you are looking at.

....and it should be working!

Edit: Some grammar, wrote this without coffee.

I have the same error when I upgraded to 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
After I rolled back to system default python, I still got the same error.

@zhongruizhi did you try what I suggested above? I posted my solution and that fixed it for me!

@anirrudh
thanks, but it seems like your solution is not quite fit for my condition. I'm not using brew, and I'm using system's default python(2.7.10) and vim.(+python/dyn -python3) .

@anirrudh it really works for me, a good solution, thanks very much

@zhongruizhi So I used to have the standard vim version provided by Apple as well, but that seems to be broken for powerline, the only fix seems to be to install vim via brew -- and as for python versions, I address that in my post above, but you need to make sure that +python3 is a thing, not +python/dyn, which was exactly what my apple provided vim had!

@anirrudh Thank you for figuring out the details. And it works.

I found the reason and a solution i think more elegent:
CFUNCTYPE at _reset_cache() function in file:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py
get memory error.
Then I jumped to this file and found such code:

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)

As you can see, CFUNCTYPE function at line 279 is added by unittest on Win64 for whatever reasons. For mac user, this line is useless and lead to memory error on macOS. So I comment out line 279, and rerun vim, there is no errors with powerline.

More Details:
The __init__.py file is system read-only file, and you need to run command csrutil disable in mac recovery mode(press command+R when booting up) to disable System Integrity Protection. After reboot, you can edit this file use root permission.

brew install vim --with-lua --with-override-system-vi
and restart shell , fixed

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

Thank you @Joshua-Chang

It worked for me

thank you @Joshua-Chang
vim is ok, but vi still wrong
`Vim: Caught deadly signal SEGV
Error detected while processing function 70_PollServerReady[7]..70_Pyeval:Vim: Finished.

line 4:
Exception MemoryError: MemoryError() in ignored
Segmentation fault: 11`

vim is ok, but vi still wrong

maybe there's a better resolution out there but I fixed that one by adding alias vi="vim" into my shell rc file

I have the same problem with @whenever77 when i use commad git commit --amend.

@kyriejoshua

try @Joshua-Chang 's suggestion, it works for me.

try @Joshua-Chang 's suggestion, it works for me.

I tried.
It works when i use vim directly, but it is still wrong when i run command git commit --amend or try to fix conflicts in command line.

Finally, I resolved this problem by reading this article. @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 Mind sharing the solution?

It's my solution. @josephtyler

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

and restart shell , fixed

For YCM users, please use YCM contacts

We are tracking a similar issue with system Vim here: https://github.com/Valloric/YouCompleteMe/issues/3271

Spoiler alert: I think it is a Mojave thing not a YCM thing.

For me, the issue started appearing after a "critical update" was installed by Mojave (eg I've been on Mojave for ages with vim/powerline working fine). Turns out it was simply a case of the wrong vim being used (eg /usr/bin/vim, Apple's built-in vim) rather than my vim from /usr/local/bin/vim. It was just a case of fixing my PATH; the update presumably reordered it.

I just started using a mac with a fresh install of Mojave and got this issue, it should be noted that I am using python3.7.

I solved it by doing the following:

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

Just replace VIM_VERSION with the version of vim that brew installed on the first line.

Can add another confirmation that this is related to the macOS Mojave update. I'm going to have to do some comparison work with another machine that has NOT been updated yet to see what system libraries changed. I'm sure it is something that changed in the default python 2.7(.10) installation or something with a related library.

Had this same issue coming from bash to zsh, what fixed it for me was exporting my PATH. export PATH=$HOME/bin:/usr/local/bin:$PATH

I already had python 3.7.3, vim (the version included from macvim compiled by [email protected]), and already had Mojave. Was only making transition to zsh.

So I'm busting my head against a wall trying to figure out why this isn't working for me the day after I'm forced to upgrade my work laptop to Mojave. I followed the above guides, and got powerline working in vim again, but for the LIFE of me, it wouldn't work correctly when I try to git commit.

I double checked in my .zshrc that I had my editor set to be vim. I then alias vi=vim, and still no dice.

Then after re-installing powerline and vim about a hundred different times I noticed it in the error message (this one being a much smaller error message after restarting my terminal window again and NOT starting tmux or anything else:

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.

Right there: /usr/bin/vim

So I double checked, and low-and-behold in my .gitconfig I had the following lines:

[core]
editor = /usr/bin/vim

So that got changed to just editor = vim

TL;DR: If you're still having problems with your git commit vim install double check that your .gitconfig is not pointing at system vim.

Was this page helpful?
0 / 5 - 0 ratings