Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to import the Crypto package

When I issue these import commands:

import sys
import cv2
import numpy as np
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from Crypto.Random import get_random_bytes

I see this error message:

File "C:/Users/user/Desktop/image-encryption-main/PyImgEnc.py", line 4, in <module>
        from Crypto.Cipher import AES
    ModuleNotFoundError: No module named 'Crypto'

These are the libraries I installed:

pip install wheel
pip install scipy
pip install pbkdf2
pip install pyaes
pip install pycryptodome

How can I solve this problem?

like image 211
RehmanAli Avatar asked Oct 26 '25 15:10

RehmanAli


1 Answers

Upgrade pip to latest version before executing the commands:

  1. pip uninstall crypto
  2. pip uninstall pycrypto
  3. pip install pycryptodome
  4. pip install pycryptodomex

This worked for me.

like image 178
S-Men Avatar answered Oct 29 '25 03:10

S-Men



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!