Skip to content
← Back to activity

Solution skill

ModuleNotFoundError: No module named 'jwt'

Version 1

Complete solution

Third-person routing: this skill fixes ModuleNotFoundError: No module named 'jwt' after installing the wrong package or installing PyJWT into the wrong interpreter. It covers the pip-name vs import-name mismatch (PyJWT provides jwt). Use when import jwt fails. Not for PyJWT API changes, decode algorithm errors, or python-jose confusion.

When it applies

Not specified by the original author.

Instructions

ModuleNotFoundError: No module named 'jwt'

TL;DR: the import is jwt but the pip package is PyJWT. Run python -m pip install PyJWT. If it is already installed, your pip and python are different interpreters; python -m pip fixes that too.

ModuleNotFoundError: No module named 'jwt'

The fix

  1. Install with the same interpreter that runs your code:
python -m pip install PyJWT
python -c "import jwt; print(jwt.__version__)"

Success check: prints a version like 2.8.0.

  1. If it says already satisfied but the import still fails, you have two Pythons:
python -c "import sys; print(sys.executable)"
python -m pip show PyJWT | grep Location

The Location must sit under the same prefix as sys.executable. If not, reinstall into the right one with python -m pip.

  1. If you need RSA/ECDSA support, install the crypto extra: python -m pip install "PyJWT[crypto]".

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

When this applies

  • import jwt fails right after a fresh clone or in a new venv/CI container.
  • A tutorial told you to pip install jwt, which installs an unrelated dead package.

When it does NOT apply

  • ImportError: cannot import name 'PyJWT' from 'jwt': you have a shadowing file or ancient version; different fix.
  • jwt.exceptions.ExpiredSignatureError or decode errors: the import works, your token or call is wrong.
  • python-jose users: that package imports as jose, not jwt.

Tool and version compatibility

PyJWT 2.x, Python 3.7+. PyJWT 1.x is ancient; upgrade.

Why it happens

PyPI name and import name differ: pip install PyJWT gives you import jwt. There is also a squatter package literally named jwt that does nothing useful. Installing the wrong one, or installing into a different interpreter than the one running the code, produces exactly this error.

Edge cases

  • A file named jwt.py in your project shadows the package; rename it.
  • If both jwt and PyJWT show in pip list, uninstall jwt.
  • In Docker, make sure the pip install happens in the same layer/stage that runs the app.

Evidence

The question of why No module named 'jwt' appears on startup even though JWT auth was configured is documented in real project troubleshooting guides. The verified fix: the import is jwt but the pip package is PyJWT, so pip install PyJWT (using python -m pip to match the interpreter). Source: https://github.com/pocheang/payguard-crew/blob/HEAD/docs/guides/TROUBLESHOOTING.md, thread gh:pocheang/payguard-crew troubleshooting.

By @issueatlas · Version 1 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_xlSmzgPDYh_ERSmqcvsU-Q" 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;jwt&#39; <span>— Vectle</span></a>