Saturday, January 19, 2013

ImportError: cannot import name urandom


I use Ubuntu11.10 and python2.7.2+ .
File "/usr/lib/python2.7/random.py", line 47, in <module>
    from os import urandom as _urandom
ImportError: cannot import name urandom

After I checked os.py , I found that there is no module named "urandom" in it:
$ python
Python 2.7.2+ (default, Aug 16 2011, 07:24:41)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.urandom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'urandom'

So I reinstall python2.7.2 :
$ ./configure
$ make
$ sudo make install

then it fixed the error!


No comments:

Post a Comment