Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OSX 10.8.2 (Fails to load properly) #39

Closed
while1eq1 opened this issue Jan 10, 2013 · 25 comments
Closed

Mac OSX 10.8.2 (Fails to load properly) #39

while1eq1 opened this issue Jan 10, 2013 · 25 comments

Comments

@while1eq1
Copy link

In Mac OSX 10.8.2 im unable to get powerline to work, it bails everytime vim lauches with the following error:

Error detected while processing /Users/wbroach/.vimrc:
line 1:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named powerline.ext.vim

I can verify that the module is in fact installed:

Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import powerline.ext.vim
dir(powerline)
['builtins', 'doc', 'file', 'name', 'package', 'path', 'ext']

It can be found in the following location on my system:

/Library/Python/2.7/site-packages/Powerline-beta-py2.7.egg/powerline/ext/vim/powerline.vim
/Library/Python/2.7/site-packages/powerline/ext/vim/powerline.vim

Im using just a plain blank .vimrc with just one line, shown below:

python from powerline.ext.vim import source_plugin; source_plugin()

My sys specs are as follows:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 16 2012 15:12:57)
Python 2.7.2 (default, Jun 20 2012, 16:23:33)

I can verify that vim is in fact using the correct python version that the module is installed to

in vim:

:python import sys
:python print(sys.version)
2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]
Press ENTER or type command to continue

Please advise

@Lokaltog
Copy link
Member

That's strange. What's the output when you run this inside vim:

python import sys; print(sys.path)

@while1eq1
Copy link
Author

python import sys; print(sys.path)

['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/pyt
hon2.7/plat-mac/lib-scriptpackages', '/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/us
r/lib/python2.7/lib-dynload']
Press ENTER or type command to continue

@while1eq1
Copy link
Author

Works now.

It was missing the following path: /Library/Python/2.7/site-packages

I added this: python import sys; sys.path.append("/Library/Python/2.7/site-packages")
above: python from powerline.ext.vim import source_plugin; source_plugin()
in my vimrc

This is a fresh new install of OSX, This might want to get added to the readme somewhere as to help those who run into this same issue on OSX.

@Lokaltog
Copy link
Member

It shouldn't really be necessary to manually append the path if you've installed the package system-wide, but if you installed it local to your user it may act differently on OS X. Anyways, I'll add some info about this to the troubleshooting section of the docs for others who may run into the same issue.

@while1eq1
Copy link
Author

I did check to make sure that powerline was in fact installed system-wide, It seems as though on a new installation of Mac OSX 10.8.2 Mountain Lion that the '/Library/Python/x.x/site-packages' is not in the PYTHONPATH for vim by default.

@qqshfox
Copy link

qqshfox commented Jan 11, 2013

I had this problem too and got it resolved.

System Vim and System Python

$ port select python
Available versions for python:
    none (active)
    python25-apple
    python26
    python26-apple
    python27
    python27-apple

in /usr/bin/vim:

:python import sys; print(sys.path)
['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/python2.7/plat-mac/lib-scriptpackages
', '/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload']

System Vim and MacPorts' Python

$ sudo port select python python27
Selecting 'python27' for 'python' succeeded. 'python27' is now active.
:python import sys; print(sys.path)
['/Users/hanfei/.config/powerline', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/powerline', '/opt/local/Library/Fra
meworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/readline-6.2.2-py2.7-macosx-10.7-inte
l.egg', '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/gevent-1.0rc1-py2.7-macosx-10.8-intel.egg', '/usr/local/lib/
wxPython-unicode-2.8.12.1/lib/python2.7/site-packages', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode', '/opt/local/L
ibrary/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/opt/local/Libr
ary/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions
/2.7/Extras/lib/python', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Ver
sions/2.7/lib/python2.7/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/opt/local/Library/Frameworks/Python
.framework/Versions/2.7/lib/python2.7/site-packages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11
-py2.7.egg-info', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PIL', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7']

This is not a system-wide python.

System Vim and Apple's Python

$ sudo port select python python27-apple
Selecting 'python27-apple' for 'python' succeeded. 'python27-apple' is now active.
:python import sys; print(sys.path)
['/Users/hanfei/.config/powerline', '/Library/Python/2.7/site-packages/powerline', '/Library/Python/2.7/site-packages/readline-6.2.2-py2.7-macosx-10.7-intel.egg
', '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/gevent-1.0rc1-py2.7-macosx-10.8-intel.egg', '/usr/local/lib/wxPyt
hon-unicode-2.8.12.1/lib/python2.7/site-packages', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode', '/System/Library/F
rameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks
/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/F
rameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python'
, '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-o
ld', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PIL', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7']

This should work.

MacVim and any version Python

:python import sys; print(sys.path)
['/Users/hanfei/.config/powerline', '/Library/Python/2.7/site-packages/powerline', '/Library/Python/2.7/site-packages/readline-6.2.2-py2.7-macosx-10.7-intel.egg
', '/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/gevent-1.0rc1-py2.7-macosx-10.8-intel.egg', '/usr/local/lib/wxPyt
hon-unicode-2.8.12.1/lib/python2.7/site-packages', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode', '/System/Library/F
rameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks
/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/F
rameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python'
, '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-o
ld', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/
python/PyObjC', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/PIL', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7']

This should work too.

@ehynds
Copy link

ehynds commented Jan 18, 2013

I had the same issue with homebrew-installed python. I had to add /usr/local/lib/python2.7/site-packages to my path.

@gmcmillan
Copy link

I had the same issue. I'm using the system installed version of Python (2.7). Not homebrew.

# file /Library/Python/2.7/site-packages/powerline/ext/vim/powerline.vim
/Library/Python/2.7/site-packages/powerline/ext/vim/powerline.vim: ASCII Java program text

from vim:

:python import sys; print(sys.path)

['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/Extras/lib/python', '/usr/lib/python2.7/lib-tk', '/
usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload']

Adding the following line above the powerline import in my vimrc fixed the issue:

python import sys; sys.path.append("/Library/Python/2.7/site-packages")

@acook
Copy link

acook commented Jan 20, 2013

I had to add this to get mine to work:

python import sys; sys.path.append("/usr/local/lib/python2.7/site-packages/")

OSX Lion, brew, macvim. I tried the above approaches and wasn't able to get it working.

@while1eq1
Copy link
Author

That's probably because you installed a seperate python (via brew or
something) and installed powerline into that python's site-packages instead
of the systems standard python site packages.

$ which python
^^ will probably say /usr/local/bin/python (which is not the system default
python)

Also sounds like you have /usr/local/bin in front of /usr/bin in you PATH.

OSX by default does not use /usr/local, 3rd party products like brew use
that location.

On Sunday, January 20, 2013, Anthony Cook wrote:

I had to add this to get mine to work:

python import sys; sys.path.append("/usr/local/lib/python2.7/site-packages/")

OSX Lion, brew, macvim. I tried the above approaches and wasn't able to
get it working.


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-12467215.

@acook
Copy link

acook commented Jan 20, 2013

I did specify brew. Either way, this plugin is extremely finicky at this stage. And its worse if you're not a python developer, but have been using Powerline for a long time. Pretty much everything has to be ripped out and started over.

I wrote up my experiences getting the Vim (MacVim and Ubuntu commandline) module working, hopefully it helps someone else:
http://acook.github.com/powerline

@Fl4t
Copy link

Fl4t commented Jan 29, 2013

I have an ImportError too and nothing works for me :

Error detected while processing /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/powerline.vim:
line   10:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/powerline/core.py", line 10, in <module>
from powerline.lib import underscore_to_camelcase
File "/usr/local/lib/python2.7/site-packages/powerline/lib/__init__.py", line 1, in <module>
from powerline.lib.memoize import memoize  # NOQA
File "/usr/local/lib/python2.7/site-packages/powerline/lib/memoize.py", line 8, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
line   11:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'Powerline' is not defined
Press ENTER or type command to continue```

In vimrc :

python import sys; print(sys.path) :

['/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framewo
rk/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg', '/Library/Python/2.7/site-packages/regetron-1.4-py2.7.egg', '/usr/local/lib/python2.7/site-packages/pip-1.2
.1-py2.7.egg', '/usr/local/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/us
r/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darw
in', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/p
ython2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/usr/local/Cellar/python/2.7.3/Frameworks/Python
.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.3/Frame
works/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/warez/Library/Python/2.7/lib/python/site-packages', '/Library/Python/2.7/site-packages', '/usr/local/lib/pyth
on2.7/site-packages', '/usr/local/lib/python2.7/site-packages/']

OS X 10.7.5, python (homebrew)

@carwin
Copy link

carwin commented Feb 2, 2013

I was able to get this up and running successfully this morning, so I thought I would share the process.

I have it running with:

  • iTerm2 1.0.0.20130201-nightly
  • Python 2.7.3
  • Vim 7.3.798
  • Zsh 5.0.2

iTerm2

I used the latest nightly release from here: http://iterm2.com/nightly/latest

Python

I decided to try using Homebrew's version -- brew install python gave me version 2.7.3.

Vim

I used a brew for this as well, using part of the install command in the docs. The brew for Vim requires Mercurial, but there wasn't anything special about that install.

brew install mercurial;
brew install vim --env-std --override-system-vim --enable-pythoninterp;

Modified $PATH

As others have noted, Homebrew installs things into /usr/local/bin. Rather than try to deal with my existing $PATH declarations, I just commented out all of them in ~/.zshrc and threw this at the top:

export PATH="/usr/local/bin:$PATH"

Installing Powerline

After making sure that the version of Python in my path was the correct one ( /usr/local/bin/python ), I basically just followed the instructions for OSX Installation.

  • pip install --user git+git://github.com/Lokaltog/powerline
  • Added this to ~/.vimrc:
    • python from powerline.bindings.vim import source_plugin; source_plugin()
    • source /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/plugin/source_plugin.vim
  • Added this to ~/.zshrc:
    • . /usr/local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh
  • And this went into ~/.tmux.conf:
    • source /usr/local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf

I hope someone finds this helpful.

Screen Shot 2013-02-02 at 12 34 48 PM


In case you're compiling Vim yourself, here's the big features list from my compile:

Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_sgr -mouse_sysmouse
+mouse_urxvt +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile +python
-python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save

@jfl209
Copy link

jfl209 commented Feb 4, 2013

carwin, followed your steps. when i try to start Vim I get:

ImportError: No module named site

Any thoughts?

@Fl4t
Copy link

Fl4t commented Feb 6, 2013

Same as above.

@Fl4t
Copy link

Fl4t commented Feb 7, 2013

fixed with 8b8de32
Thx a lot !

@andyleejordan
Copy link

I got Powerline running in Vim this evening using:

  • Mac OS X 10.8.2
  • Python 2.7.3
  • Vim 7.3.831
  • iTerm2 Build 1.0.0.20130210

Similar to carwin, I used brew to install Python 2.7.3, Mercurial, and standard Vim (not MacVim). Homebrew requires /usr/bin/local to be at the start of your path so that brew installs override anything else.

brew install vim --env-std --override-system-vim --enable-pythoninterp;

Installed Powerline via pip:

pip install --user git+git://github.com/Lokaltog/powerline

Now here's what I had to fix, the Powerline bindings filenames changed. Add this to .vimrc:

source /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/plugin/powerline.vim

This got Powerline enabled in Vim, but I'm still having issues with the fonts. I do have the most recent patched version of Menlo for Powerline, and it works fine for the Powerline-inspired "agnoster" zsh theme. UTF-8 is set across the board, and iTerm2 is using the font.

@andyleejordan
Copy link

Patching Menlo manually with fontforge from brew, and my system's Menlo font has fixed the fonts issue with Vim Powerline... my agnoster theme is no longer functioning properly. Strange.

Also, I was able to uninstall Powerline via pip and install it using Vundle, still working now.

Edit: I've fixed the agnoster oh-my-zsh theme to use the Powerline beta glyphs.

@ootoovak
Copy link

Using: Mountain Lion, MacVim and Homebrew

For me the problem was the Homebrew MacVim was not building against the Homebrew Python even with the Python flags set. This http://superuser.com/a/440982 post solved that problem for me by hacking the install script. I made the changes to my MacVim Homebrew install script and reinstalled it with the following command.

brew reinstall macvim --env-std --override-system-vim

And in my .vimrc.before file:

set rtp+=~/.janus/powerline/powerline/bindings/vim

And in my .vimrc.after file:

set guifont=Inconsolata-dz\ for\ Powerline:h12

@samueljohn
Copy link

Hi all. I pushed an update to Homebrew and now MacVim (and Vim in another commit) both build against system and against a (newer) brewed python. Brewed Python is preferred, if available. I tested the python bindings with powerline and works great for me now. We assume that this is a upstream issue with how (Mac)Vim builds on OS X, so now we pass -L ... and -F ... flags now to force brewed python - if you have a brewed Python. Note that you should upgrade your brewed python to 2.7.5 if not done already.

Downside is that we had to disable --with-python3 because the window just disappeared and Python 2.x bindings broke. We are waiting for upsteam in this case.

Oh, and don't rename anything in /System, please.

But the good is brew install macvim should just work™ as expected, again!

@ootoovak
Copy link

That's great. Thanks for the effort @samueljohn. 👍

@lunohodov
Copy link

When trying to install Powerline, it complained with

error: can't combine user with prefix, exec_prefix/home, or install_(plat)base

I am running on 10.8.4 using a brew-installed Python 2.7.5.

The solution was simple and is documented on http://stackoverflow.com/questions/4495120/combine-user-with-prefix-error-with-setup-py-install

Cheers

@RobertAudi
Copy link

I got the powerline (kinda) working, but not the zsh bindings. When I source the powerline.zsh file I get a command not found error:

zsh: command not found: powerline

@njuaplusplus
Copy link

If you use brew to install python, you can just run without the --user option. #552 (comment)

@samueljohn
Copy link

Yes, see my comment there #552 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests