Fabric: ImportError: No module named Crypto

Created on 29 Apr 2016  ·  3Comments  ·  Source: fabric/fabric

Hi there,

I have a private project that depends on fabric. Specifically, we pin fabric==1.10.2.

Today, builds of this project have started mysteriously failing with the following stacktrace:

19:22:54.233     from fabric import api as fabric_api
19:22:54.233   File "/home/go/work/pipelines/make-ci-00/code/.venv/local/lib/python2.7/site-packages/fabric/api.py", line 11, in <module>
19:22:54.233     from fabric.decorators import (hosts, roles, runs_once, with_settings, task,
19:22:54.233   File "/home/go/work/pipelines/make-ci-00/code/.venv/local/lib/python2.7/site-packages/fabric/decorators.py", line 9, in <module>
19:22:54.233     from Crypto import Random
19:22:54.233 ImportError: No module named Crypto

Fabric has been pinned to the same version for weeks. Manually installing pycrypto alongside fabric resolves this issue.

Despite explicitly importing Crypto.Random, fabric's only dependency is paramiko, and pycrypto isn't referenced anywhere aside from paramiko docs.

IMO if you're importing pycrypto symbols explicitly within fabric, pycrypto should be cited as a dependency within setup.py.

Thanks!

Most helpful comment

Paramiko 2.0 was recently released (and I think depends on cryptography rather than pycrypto). The 1.10.2 version of setup.py doesn't properly restrict the version of paramiko, but the 1.10.3 version does. Maybe upgrading to 1.10.3 will help.

Looks like this was changed in c7d3034b5f217f2b4e7989f2c8e9bbea335be270

All 3 comments

Paramiko 2.0 was recently released (and I think depends on cryptography rather than pycrypto). The 1.10.2 version of setup.py doesn't properly restrict the version of paramiko, but the 1.10.3 version does. Maybe upgrading to 1.10.3 will help.

Looks like this was changed in c7d3034b5f217f2b4e7989f2c8e9bbea335be270

Can confirm that bumping to 1.11.1 has fixed this issue. Wonder why 1.10.2 decided to break today...

@jamesob was this triggered by reinstalling Fabric in a new environment? As @gtback noted, paramiko changed recently and we put out earlier Fab releases that pin to paramiko<2 to avoid this kind of thing. You weren't on one of those which is likely why things broke.

That said, I didn't realize we were directly importing Crypto anywhere; just looked and yea, we had to do some dumb tweak to deal with a PyCrypto + parallelization quirk. That'll have to change if we ever undo the Paramiko version pin (which I would like to do sometime probably, once we're sure paramiko 2 is stable). So, thanks for surfacing this :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acdha picture acdha  ·  4Comments

peteruhnak picture peteruhnak  ·  6Comments

peteruhnak picture peteruhnak  ·  4Comments

amezin picture amezin  ·  5Comments

bitprophet picture bitprophet  ·  4Comments