Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1585

Python • Why does importing 'Crypto' not work, but importing 'Cryptodome' does?

$
0
0
In the process of trying to run a thrid party github project I got the error

Code:

 No module named 'Crypto'
despite having installed python3-pycryptodome, on RpiOS Lite bookworm (64) on a Pi 4. That third party github project imports AES exactly like the first line of the first of pycryptodome's own examples on https://www.pycryptodome.org/src/examples, i.e.

Code:

 from Crypto.Cipher import AES
.

Now, I'm no Python person, but I went through the list of things I could think of, but pip complained about externally managed python, so I dismissed it, and I'm not using any virtual environment afaik.

When I try:

Code:

$ python Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from Crypto.Cipher import AESTraceback (most recent call last):  File "<stdin>", line 1, in <module>ModuleNotFoundError: No module named 'Crypto'
This was the most minimal example I could think of. Same result when I repeat this on Debian 14 forky on a PC.

When I import Cryptodome instead there are no complaints:

Code:

$ python Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from Cryptodome.Cipher import AES>>> 
What's installed:

Code:

$ apt list --installed python\*crypto\*Listing... Donepython3-pycryptodome/oldstable,now 3.11.0+dfsg1-4 arm64 [installed]
Sooo... What have I misunderstood this time? :-)

Statistics: Posted by Levajn — Wed Sep 10, 2025 2:06 pm



Viewing all articles
Browse latest Browse all 1585

Trending Articles