ImportError:没有名为Crypto的模块--pycrypto

时间:2017-09-08 12:39:54

标签: python pycrypto

这是我运行fab时获得的回溯:prod deploy

Traceback (most recent call last):
  File "/usr/bin/fab", line 9, in <module>
    load_entry_point('Fabric==1.10.2', 'console_scripts', 'fab')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2662, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2316, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2322, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/fabric/main.py", line 19, in <module>
    from fabric import api, state, colors
  File "/usr/lib/python2.7/dist-packages/fabric/api.py", line 11, in <module>
    from fabric.decorators import (hosts, roles, runs_once, with_settings, task,
  File "/usr/lib/python2.7/dist-packages/fabric/decorators.py", line 9, in <module>
    from Crypto import Random
ImportError: No module named Crypto

我尝试用stackoverflow上的许多类似的答案/问题解决我的问题,但没有什么进展顺利。是的,我已经尝试过pip install pycryptopip install Cryptopip install crypto。我该如何解决这个问题?

pip install pycrypto
Requirement already satisfied: pycrypto in ./venv/lib/python2.7/site-packages/pycrypto-2.6.1-py2.7-linux-x86_64.egg

我正在使用virtualenv并且已激活。

2 个答案:

答案 0 :(得分:0)

安装它:

pip install pycrypto

答案 1 :(得分:0)

您错过了Crypto模块,我知道您已尝试pip install pycrypto,但您的pip可能是for python 3?请尝试pip2 install pycrypto

刚刚看到你的编辑,你已经在virtualenv中安装了pycrypto,但你的frabic没有安装在同一个virtualenv中。