1

I am using Ubuntu and virtualenv, and I am having this recurring problem, while attempting to use Fabric to create a deployment script. Fabric depends on paramiko, which depends on PyCrypto.

Each time I try to use Fabric, or PyCrypto directly, I get this error:

ImportError: cannot import name Random

I have tried reinstalling with pip install -U PyCrypto. I have also tried installing the python-crypto and python-crypto-dbg packages with Aptitude, to no avail. I still get the same error. Anyone have any ideas that might help me solve this problem? Thanks in advance!

tommytwoeyes
  • 483
  • 5
  • 19

2 Answers2

0

It's possible that there's a file name collision in your the directory from which you're running Fabric. Do you have a file called Crypto.py in your project?

Can you get Crypto.Random to import from outside of your project directory? (but still using your virtualenv. Ipython is a big help here.)

ralfonso
  • 53
  • 1
  • 5
  • That's a good suggestion. I grep'd for that using ls recursively, but the only files with Crypto in the name are in the PyCrypto package itself and in the PyCrypto egg. I'm not sure how it would be possible to import anything from outside of the project directory of a virtualenv while still using the virtualenv. How would that work? – tommytwoeyes Jul 29 '11 at 18:25
  • I tried activating the virtualenv from iPython, then cd'ing up, out of the project directory and importing Crypto.Random there. Still, it did not work. I get the same error. I can import Crypto, but I still get an ImportError that says, "Cannot import name Random" – tommytwoeyes Aug 01 '11 at 14:41
0

I've had the same trouble in the past using Ubuntu. I no longer have a Ubuntu install available, but on my old 10.04 box, the file Random in the Crypto directory was missing. Make sure it exists, if it doesn't, that's the problem.

Perkins
  • 2,409
  • 25
  • 23