ModuleNotFoundError: No module named 'Crypto' (tested fix)

ModuleNotFoundError: No module named 'Crypto' means the library that provides Crypto.Cipher is not installed. The obvious fix, pip install crypto, installs a different package. We reproduced it in a clean container and tested the fix.

1. The trap: pip install crypto installs a different package

python -m venv /tmp/v
/tmp/v/bin/python -c "from Crypto.Cipher import AES"
/tmp/v/bin/python -m pip install -q crypto
/tmp/v/bin/python -m pip show crypto | grep -E '^(Name|Version|Summary)'
/tmp/v/bin/python -c "from Crypto.Cipher import AES"

Output (sh -x, so each command is echoed with a +):

+ python -m venv /tmp/v
+ /tmp/v/bin/python -c 'from Crypto.Cipher import AES'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
+ /tmp/v/bin/python -m pip install -q crypto
+ /tmp/v/bin/python -m pip show crypto
+ grep -E '^(Name|Version|Summary)'
Name: crypto
Version: 1.4.1
Summary: Simple symmetric GPG file encryption and decryption
+ /tmp/v/bin/python -c 'from Crypto.Cipher import AES'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'

The import name Crypto does not match any package called "Crypto". pip install crypto succeeds, but it installs crypto 1.4.1, an unrelated GPG file-encryption tool, and the import still fails.

2. Fix: install pycryptodome

/tmp/v/bin/python -m pip install -q pycryptodome
/tmp/v/bin/python -c "from Crypto.Cipher import AES; import Crypto; print('ok', Crypto.__version__)"

Output (sh -x, so each command is echoed with a +):

+ /tmp/v/bin/python -m pip install -q pycryptodome
+ /tmp/v/bin/python -c 'from Crypto.Cipher import AES; import Crypto; print('"'"'ok'"'"', Crypto.__version__)'
ok 4.1.0

pycryptodome provides the Crypto package, so code written for the old PyCrypto library (from Crypto.Cipher import AES) imports unchanged. Install it with the same interpreter that runs your code (python -m pip; see No module named 'requests' for why).

3. "No module named 'crypto.Cipher'": lowercase crypto

# lowercase "crypto" is the unrelated package from block 1
/tmp/v/bin/python -c "from crypto.Cipher import AES"
ls /tmp/v/lib/python3.14/site-packages | grep -i crypt

Output (sh -x, so each command is echoed with a +):

+ /tmp/v/bin/python -c 'from crypto.Cipher import AES'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from crypto.Cipher import AES
ModuleNotFoundError: No module named 'crypto.Cipher'
+ ls /tmp/v/lib/python3.14/site-packages
+ grep -i crypt
Crypto
crypto
crypto-1.4.1.dist-info
pycryptodome-4.1.0.dist-info

The name is case-sensitive. crypto (lowercase) is the package from block 1, which has no Cipher submodule, so you get No module named 'crypto.Cipher'. Use a capital C, and pip uninstall crypto if you installed it by mistake.

4. pycryptodomex installs Cryptodome, not Crypto

python -m venv /tmp/w
/tmp/w/bin/python -m pip install -q pycryptodomex
/tmp/w/bin/python -c "from Cryptodome.Cipher import AES; print('Cryptodome ok')"
/tmp/w/bin/python -c "from Crypto.Cipher import AES"

Output (sh -x, so each command is echoed with a +):

+ python -m venv /tmp/w
+ /tmp/w/bin/python -m pip install -q pycryptodomex
+ /tmp/w/bin/python -c 'from Cryptodome.Cipher import AES; print('"'"'Cryptodome ok'"'"')'
Cryptodome ok
+ /tmp/w/bin/python -c 'from Crypto.Cipher import AES'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'

pycryptodomex is the same library under the import name Cryptodome, so it can sit next to an old PyCrypto install. If a requirements file pins pycryptodomex, import from Cryptodome.Cipher import AES; if the code says Crypto, install pycryptodome instead.

Related: ModuleNotFoundError vs ImportError · No module named 'yaml' · No module named 'dotenv'.

Frequently asked questions

Which package provides the Crypto module?

pycryptodome. Install it with python -m pip install pycryptodome; it keeps the old PyCrypto import path, from Crypto.Cipher import AES.

Why doesn't pip install crypto fix it?

The PyPI package named crypto (1.4.1) is an unrelated GPG file-encryption tool. It installs a lowercase crypto module with no Cipher submodule.

What is the difference between pycryptodome and pycryptodomex?

Same library, different import names: pycryptodome installs Crypto, pycryptodomex installs Cryptodome.

Written with AI assistance. Measured on 2026-10-23 in the python:3-alpine Docker image (Python 3.14): pip install crypto (1.4.1), pycryptodome 4.1.0, lowercase crypto.Cipher, and pycryptodomex. Every block was run verbatim and its output pasted unedited. PlainHeaders is our extension; Python and pycryptodome are free.