8

I have installed pycryptodomex module on python 3.6.5 but when i try to execute the below call, i get the error mentioned in the headline

from Crypto.Cipher import AES

I want to encrypt a file using AES. How to proceed now ?

Aran-Fey
  • 30,995
  • 8
  • 80
  • 121
achilles59
  • 83
  • 1
  • 1
  • 3
  • Possible duplicate of [ImportError: No module named Crypto.Cipher](https://stackoverflow.com/questions/19623267/importerror-no-module-named-crypto-cipher) – Black Thunder Aug 13 '18 at 14:29

5 Answers5

26
>> pip install pycryptodome

from Crypto.Cipher import AES  #Works

or

>> pip install pycryptodomex
from Cryptodome.Cipher import AES 

For python3 the package name is now pycryptodome or pycryptodomex

If you need compatibility with your project with Python2 use pycryptodome or else use pycryptodomex which is a library independent of the old PyCrypto.

NoorJafri
  • 1,333
  • 11
  • 20
6

hello i had the same problem: _an almost drop-in replacement for the old PyCrypto library. You install it with:

$ pip install pycryptodome ((3.8.2)) or the latest version go to this directory : 2) [C:\Users\s****\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\crypto]

here try to change the file name crypto to Crypto with upper case C because they import it as Crypto in every package. it works for me, good luck :)

Isaac Frost
  • 61
  • 1
  • 2
4

According to the PyPI page, pycryptodomex is available under the name Cryptodome instead of Crypto

Patrick Haugh
  • 49,982
  • 11
  • 66
  • 73
2

You will have to install the Cryptography package. Visit here for more details.

Or you can try pip install at the terminal:

pip3 install pycrypto
  • That's for Python2, he explicitly mentioned Python3. – NoorJafri Aug 13 '18 at 14:34
  • @NoorAliJafri it works for both, provided what version of python he has installed. If he has installed both all he has to do is use pip3 instead of pip. – Sparsh Shrivastava Aug 13 '18 at 14:39
  • I checked with both the versions in both the cases it's installing pycrypto but with pip3 it works to import crypto.cipher. Just mention that tiny detail. – NoorJafri Aug 13 '18 at 14:42
0

If you have installed cryptodome, you can try to create a symbolic link

ln -s Cryptodome Crypto

Zeek
  • 1
  • 1
  • I would not recommend this solution, it will work locally on his machine but will blow upon deployment. – NoorJafri Apr 16 '21 at 17:23