vimpowerlinevim-powerline

DeprecationWarning when starting Vim with Powerline enabled since Python upgrade from 3.6.5 to 3.7.0


I was happily using Powerline for Vim for a while now until today Homebrew installed a Python upgrade from 3.6.5 to 3.7.0. Since then, Powerline stopped working properly in Vim.

First, when starting Vim, there was an error saying that the powerline module could not be found, which makes sense, I guess, if pip installs packages per Python minor version.

So I installed the powerline-status package again using pip as described in the docs:

pip install powerline-status

Now, the ModuleNotFoundError is gone and I get a working powerline in Vim, but every time I start Vim I get another error saying:

/must>not&exist/foo:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
Press ENTER or type command to continue

And I have to press Enter or any other key to continue, which is annoying.

If I remove the following commands for loading Powerline (as described in the docs) from my .vimrc, the DeprecationWarning is gone, but obviously the Powerline is also gone then...

python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup

I searched their GitHub issues, but couldn't find anything related.

Does anyone know a solution for this?


Solution

  • As the error states, the imp modules is deprecated.
    As a workaround, change the commands you put into your .vimrc into the following:

    silent! python3 from powerline.vim import setup as powerline_setup
    python3 powerline_setup()
    python3 del powerline_setup
    

    the silent! keyword will suppress the error message.

    Source