Powerline: Homebrew Python 2.7.10 upgrade causing powerline to error

Created on 29 May 2015  Â·  24Comments  Â·  Source: powerline/powerline

after upgrading python to 2.7.10 and reinstalling powerline-status (2.1.4) from pip, i get the following error when loading up vim:

$ vim
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:
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
Press ENTER or type command to continue
cvim serror in environment bug

Most helpful comment

I had this after uninstalling Homebrew python 2.7.* (all versions) and installing latest which was 2.7.13 at that point.

Updated: now that Python 2.7.14 is available on Homebrew, this seems to work for brew-installed vim, macvim and Python 2:

brew uninstall vim macvim

# This may vary depending on age of your installation, with move to brew python == python3 brew uninstall python2 python@2                                                                                                                         
brew install python@2       # used by powerline / vim
brew install python3          # not required for powerline
brew info python                                                                                                 

brew install vim macvim                                                                                                                                                     
# Link into /Applications as MacVim.app (now deprecated)                                                                         
brew linkapps macvim  

I have sometimes found that I can leave vim and macvim installed if I use --ignore-dependencies when uninstalling Python 2, but YMMV

All 24 comments

Did you reinstall pip?

@sigmavirus24 Is not site module part of the Python? On my system (Gentoo) qfile /usr/lib64/python2.7/site.py reports dev-lang/python (/usr/lib64/python2.7/site.py).

@djbender I see that this issue has nothing to do with powerline: check out vim -u NONE -i NONE -N -c 'python import vim', this should fail as well, complaining about site module that cannot be loaded.

@sigmavirus24 Reinstalling pip (or powerline-status too, for that matter) doesn't seem to solve the issue.

@ZyX-I You're right, python does throw an exception when I try to do either import powerline.vim or import vim. Is there something we're missing?

@paambaati vim -u NONE -i NONE -N -c 'python import vim' throwing an exception means that this issue has absolutely nothing to do with powerline. It is better ask on vim-use (describe the result of vim -u NONE… call, _not_ powerline output) because I do not know how to fix this.

Here’s how to downgrade to 2.7.9 (for those who came here via Google as I did), which works fine with Vim (and Powerline):

brew unlink python
brew install https://raw.githubusercontent.com/Homebrew/homebrew/1681e193e4d91c9620c4901efd4458d9b6fcda8e/Library/Formula/python.rb

That’s the formula from this commit, the most recent before 2.7.10. You can then switch between the two with brew switch python <version>.

@tjanson Thanks a ton! This seems to solve the issue for now. I'd rather stick to 2.7.9 for now that deal with the vim issue.

@tjanson @paambaati I just tried this myself and discovered that weirdly enough what breaks powerline is the absence of python 2.7.9 if you follow @tjanson advise but you keep 2.7.10 linked everything works fine too. It stops working the moment you run a brew cleanup.

I hope it helps.

@MarcoDeBortoli You clearly either have Vim compiled with something 2.7.10-specific (not sure what exactly: Python libraries are named without patch portion of the version and I do not remember anything else specific) or wrong environment that somewhere still points to 2.7.9.

@ZyX-I I surely don't. My macvim has been installed via brew ages ago as per powerline documentation.
The only purpose of my comment was to tell @paambaati that if he wants he can still use powerline and python 2.7.10.
I can make a test on another mac that I have where vim is working without problem and try to run a brew cleanup and see if powerline for vim stops working if that helps

@ZyX-I I just tried and I can reproduce.

~$ brew cleanup
~$ vi anyfile

And this is the error generated

Error detected while processing /Users/debo/.vimrc:
line   83:
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
line   84:
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
line   85:
E887: Sorry, this command is disabled, the Python's site module could not be loaded.

which refers to the following lines

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

Launching the following commands solve the problem and let the user work with python 2.7.10

~$ brew unlink python
~$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/1681e193e4d91c9620c4901efd4458d9b6fcda8e/Library/Formula/python.rb
~$ brew switch python 2.7.10

I hope that helps

@MarcoDeBortoli Thanks a ton, that works!

@paambaati you are welcome. I'm glad it helped.

I tried @ZyX-I solution except I didn't have 2.7.10 in my cellar (instead 2.7.10_2) and I'm still getting the same module not loaded error.

Also, my problem isn't with powerline but rather vim-autoformat.

Any suggestions?

@RatanRSur did you try my suggestion instead?

oops, sorry, that's what I meant. I tried yours.

@RatanRSur oh I see. Did you try to ask the vim-autoformat guys about the issue?

@MarcoDeBortoli @RatanRSur What’s the point in asking this in an unrelated project’s bug tracker? If :python command does not work you should go to vim-dev if you think it is Vim bug and vim-use if you think it is not, but do not know, whose bug this is.

@ZyX-I that's exactly what I said

@MarcoDeBortoli You suggested to ask “vim-autoformat guys” (I read this as “go to vim-autoformat project bug tracker/mailing list/etc”). I am suggesting vim-dev or vim-use mailing list.

@ZyX-I because that's the plugin @RatanRSur seems to have problem with so I think it would be better. vim-dev will likely work too

I did ask the autoformat guys, was linked here from there. I'll try vim then.

I was able to keep python 2.7.10 by rebuilding macvim after upgrading.

Try:

brew uninstall macvim
brew install macvim

Arguments about if this is the appropriate place aside, @rudedogg's fix worked for me and is probably the correct answer for this annoyance.

I had this after uninstalling Homebrew python 2.7.* (all versions) and installing latest which was 2.7.13 at that point.

Updated: now that Python 2.7.14 is available on Homebrew, this seems to work for brew-installed vim, macvim and Python 2:

brew uninstall vim macvim

# This may vary depending on age of your installation, with move to brew python == python3 brew uninstall python2 python@2                                                                                                                         
brew install python@2       # used by powerline / vim
brew install python3          # not required for powerline
brew info python                                                                                                 

brew install vim macvim                                                                                                                                                     
# Link into /Applications as MacVim.app (now deprecated)                                                                         
brew linkapps macvim  

I have sometimes found that I can leave vim and macvim installed if I use --ignore-dependencies when uninstalling Python 2, but YMMV

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trusktr picture trusktr  Â·  12Comments

nfarrar picture nfarrar  Â·  11Comments

pmalek picture pmalek  Â·  11Comments

treyhunner picture treyhunner  Â·  16Comments

catskul picture catskul  Â·  11Comments