xxjjnn xxjjnn - 1 year ago 133
Python Question

Python ImportError cannot import urandom Since Ubuntu 12.04 upgrade

Upgraded Ubuntu to Precise Pangolin (12.04), and Python's Random is now broken... I suspect other things might be broken too. How do I fix Python?

File "/usr/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom

Alas, poor Python! I knew him, Random, a module of infinite
jest, of most probable chaos. He hath bore me on his randint() a
thousand times, and now how abhorr'd in my workspace it is!
My Exception Handler rises at it.

edit Running in virtualenv

Answer Source

Is this your problem?


Seems to be caused by running it in a virtual environment, and there is a work around.

BTW this was the top result in google.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download