I'm quite ashamed to ask a question like this one, but I've been trying for a couple of hours already...it seems I can't get my python version to do random things anymore. More precisely, it's missing the module urandom
.
First, here are some info about my system:
- OSX version: 10.7.4
- python version: Python 2.7.1
which python
:/opt/local/bin/python
import os; os
:<module 'os' from '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc'>
echo $PATH
:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
$ENV
and$PYTHONPATH
are empty
Now, when I have a deeper look and do vim /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py
, I can see this file requires urandom:
line 47: from os import urandom as _urandom
So, quite logically, I have failures when I try running:
>>> import random
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/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
Any ideas? Where is urandom supposed to live? I've been googling around without success so far.
It seems a lot of Ubuntu users had this problem with virtualenv, but I'm not using virtualenv, and I'm not on Ubuntu. My bet is that somehow my PATH or PYTHONPATH or ENV variables are not set properly, but I have no idea how to solve this.