0

I recently tried installing powerline-vim, but have been running into problems with it.

Every time I open a new window, I see this error:

Error detected while processing function <SNR>9_UpdateWindows..<SNR>9_pyeval:
line   1:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 1, in <module>
File "opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py", line 545, in uuid4 import random
File "opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py", line 545, in uuid4 from os import urandom as _urandom
ImportError: cannot import name urandom

When I delete this line from my .vimrc file (effectively disabling powerline-vim) the error goes away.

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

The curious thing about this is when I fire up python from the terminal, the imports work just fine.

 Python 2.7.3 (default, Nov 17 2012, 19:54:34) 
 [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import random
 >>> from os import urandom as _urandom
 >>> 

The output of which python:

/opt/local/bin/python

I am running OS X 10.8.2.

Thanks!

babaloo
  • 435
  • 5
  • 24
  • The os module does not have urandom and python is installed in /opt/. Have you built that python installation from sources yourself? It looks like Python build is missing some functionality due to absence of some libraries or configuration keys. – Ellioh Jan 28 '13 at 06:09
  • I'm running OS X 10.8.2. – babaloo Jan 28 '13 at 06:23
  • Could you edit the file that imports urandom and print sys.path and os just before the failure occurs? The only thing I think it may be is that the plugin modifies sys.path (or maybe does something else in a wrong way). – Ellioh Jan 28 '13 at 06:37

2 Answers2

2
  1. Check if your problem is related with that: Python: cannot import urandom module (OS X). Check your sys.path value. Make sure you import os module from your installation of Python, not from system Python.

  2. Check the log configure generates when you build Python for clues. Have you specified prefix when building Python?

  3. Edit the code and print os and sys.path just before the error occurs to check if the plugin changed something. If sys.path is modified, often you may find the place where it is by performing import sys; sys.path = tuple(sys.path). It does not crash on sys.path = smth, but crashes on append() and +=. Maybe that would be enough to show the place where path is modified.

Community
  • 1
  • 1
Ellioh
  • 5,162
  • 2
  • 20
  • 33
0

The problem was I was executing the wrong version of Python.

sudo port select python python27-apple

Running that line fixed it.

Thanks!

babaloo
  • 435
  • 5
  • 24