19

I am just starting to explore Python. I am trying to run an AES algorithm code and I am facing the:

ImportError: No module named Crypto.

How do you solve this?

mx0
  • 6,445
  • 12
  • 49
  • 54
AK1992
  • 211
  • 1
  • 2
  • 5
  • 8
    Install it: `pip install pycrypto` – Tuan Anh Hoang-Vu Jun 09 '15 at 16:44
  • 2
    possible duplicate of [How do I install PyCrypto on Windows?](http://stackoverflow.com/questions/11405549/how-do-i-install-pycrypto-on-windows) – Łukasz Rogalski Jun 09 '15 at 16:45
  • the trouble is, there is another package called Crypto and a lot of folks install that first. and it doesn't work. `pycrypto` is the right package.. I wonder if the command ought to be changed for disambiguation? `from pycryto.Cipher..` never seen this divergence from naming convention with other packages. – Nikhil VJ Mar 31 '18 at 13:53

4 Answers4

12

You have to install crypto package. https://pypi.python.org/pypi/pycrypto

  • 5
    I've installed it. Used : pip install pycrypto. – AK1992 Jun 09 '15 at 18:08
  • I guess you've tried to import "import crypto" But in docs,it shows like that "from Crypto.Cipher import AES" –  Jun 09 '15 at 20:51
  • Solved it . Had to change the name from crypto to Crypto. Thank you ! – AK1992 Jun 09 '15 at 22:14
  • There is another Crypto package that we end up installing instead of pycrypto. There should be a way to disambiguate.. module name to use in code ought to mirror the official name of the module. – Nikhil VJ Mar 31 '18 at 13:56
  • 2
    I get an error saying `ImportError: cannot import name Padding` whenever I type `from Crypto.Util import Padding`. I observed that the Padding file is not present in Util. How do I find a pycrypto package with Padding in Util – thegreatcoder Oct 20 '18 at 03:00
7

pip install pycryptodome

It can fix the follows:

ImportError: cannot import name 'Padding' from 'Crypto.Util'
caot
  • 3,066
  • 35
  • 37
2

Solution:

By installing pycrypto module from your virtualenv

pip install pycrypto
1

Solved when i installed pycrypto rather then crypto pip2 install pycrypto

LF00
  • 27,015
  • 29
  • 156
  • 295