Skip to content
← Back to activity

Solution skill

ModuleNotFoundError: No module named 'Crypto'

Version 1Sign in to save

Complete solution

Third-person routing: this skill fixes ModuleNotFoundError: No module named 'Crypto' after installing PyCryptodome or pycrypto. It covers the pip-name vs import-name mismatch, the Windows crypto-vs-Crypto namespace collision, and cleaning out conflicting installs. Use when code does from Crypto.Cipher import AES and the import fails. Not for Cryptodome namespace (pycryptodomex) or old pycrypto-specific errors.

ModuleNotFoundError: No module named 'Crypto'

TL;DR: the import is Crypto but the pip package is pycryptodome. Run pip install pycryptodome. If it is already installed and still fails, you have a namespace collision: pip uninstall -y crypto pycrypto pycryptodome then pip install pycryptodome.

ModuleNotFoundError: No module named 'Crypto'

The fix

  1. Install the right package:
python -m pip install pycryptodome
python -c "from Crypto.Cipher import AES; print('ok')"

Success check: prints ok.

  1. If it is already installed but still fails, check for squatters:
python -m pip list 2>/dev/null | grep -i -E "crypto"

If you see crypto or pycrypto alongside pycryptodome, nuke all three and reinstall only pycryptodome:

python -m pip uninstall -y crypto pycrypto pycryptodome
python -m pip install --no-cache-dir pycryptodome
  1. On Windows, check site-packages for a lowercase crypto folder and delete it by hand if the uninstall left it behind.

Agent? Search Vectle for more: curl -s 'https://vectle.com/api/v1/search?q=pycryptodome+No+module+named+Crypto'

When this applies

  • from Crypto.Cipher import AES (or any Crypto.* import) fails.
  • You ran pip install crypto and expected the Crypto namespace; that is a different, unrelated package.

When it does NOT apply

  • Your code imports Cryptodome (with an o): that needs the pycryptodomex package instead.
  • ImportError: cannot import name 'AES' from 'Crypto.Cipher': the namespace exists but something else is off; see the AES variant skill.

Tool and version compatibility

pycryptodome 3.x, Python 3.6+, Windows/Linux/macOS. pycrypto is dead; do not install it.

Why it happens

PyCryptodome installs under the Crypto namespace but is published as pycryptodome on PyPI. The unrelated crypto package claims the same namespace, and on Windows the filesystem is case-insensitive so crypto and Crypto collide. pip then installs PyCryptodome's files into the squatter's directory.

Edge cases

  • Multiple interpreters: always use python -m pip so pip and python are the same environment.
  • A file named Crypto.py in your project shadows the package; rename it.
  • pycryptodomex is the conflict-free alternative (from Cryptodome.Cipher import AES) if you must coexist with old pycrypto.

Evidence

The question of why No module named Crypto appears on Windows even after installing PyCryptodome is answered in the official PyCryptodome FAQ. The verified fix: the similarly-named crypto package squats the Crypto namespace on case-insensitive filesystems, so run pip uninstall crypto, pip uninstall pycryptodome, then pip install pycryptodome. Source: https://github.com/legrandin/pycryptodome/blob/HEAD/Doc/src/faq.rst, thread gh:legrandin/pycryptodome faq.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_yYUlQSrr4W6sVcUbM3piAQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ModuleNotFoundError: No module named &#39;Crypto&#39; <span>— Vectle</span></a>

ModuleNotFoundError: No module named 'Crypto' | Vectle