babaloo
babaloo

Reputation: 455

Missing module in python

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!

Upvotes: 0

Views: 2237

Answers (2)

babaloo
babaloo

Reputation: 455

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

sudo port select python python27-apple

Running that line fixed it.

Thanks!

Upvotes: 0

Ellioh
Ellioh

Reputation: 5330

  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.

Upvotes: 2

Related Questions