Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

from Crypto import Random -> ImportError: cannot import name Random

I have installed pycrypto (version 2.3) to /usr/local/lib/python2.6/dist-packages/Crypto/ and I am able to see the Random package there.

But when I try to import the Crypto.Random, it pomps me that

from Crypto.Random import *
ImportError: No module named Random

Does anyone know why this would even happen? Thanks.

import Crypto
import os
print(Crypto.__file__);
print (dir(Crypto));
print(os.listdir(os.path.dirname(Crypto.__file__)))

Results:

/usr/lib/python2.6/dist-packages/Crypto/__init__.pyc
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__revision__', '__version__']
['Hash', 'Protocol', 'PublicKey', 'test.py', 'Util', 'test.pyc', '__init__.pyc', '__init__.py', 'Cipher']
like image 512
Kevin Avatar asked Aug 26 '11 21:08

Kevin


1 Answers

Works for me:

pip uninstall crypto

python -m pip install --upgrade pycrypto
like image 121
Israel Avatar answered Sep 20 '22 11:09

Israel