ImportError: cannot import name urandom
import os, sys, imp, types, tempfile, optparse File "/usr/lib/python2.7/tempfile.py", line 34, infrom random import Random as _Random File "/usr/lib/python2.7/random.py", line 47, in from os import urandom as _urandom ImportError: cannot import name urandom
You’re using a virtualenv, you’re probably on Debian or Ubuntu, and you upgraded python through apt-get.
To fix it:
virtualenv /path/to/your/virtualenvironment
Tags: virtualenv
June 11th, 2012 at 8:52 am
Hi,
So how did you sort the error out? I’m getting the “cannot import name urandom” when starting django in a virtualenv after upgrading to ubuntu 12.04. Any clues? Thanks.
June 11th, 2012 at 9:02 am
Ok, solved. for the record, I just recreated the virtual env:
$ virtualenv –no-site-packages ~/some-path/myvirtualenv
$ source ~/some-path/myvirtualenv/bin/activate
and it works. black magic. :-/