ModuleNotFoundError: No module named 'oauthlib'
Explains why `import oauthlib` throws ModuleNotFoundError and how to fix it with `pip install oauthlib`. Use when oauthlib is missing, often surfacing through requests-oauthlib or authlib. Not for OAuth flow errors.
ModuleNotFoundError: No module named 'oauthlib'
TL;DR: run pip install oauthlib. It usually arrives transitively via requests-oauthlib, so declare it directly.
ModuleNotFoundError: No module named 'oauthlib'The fix
pip install oauthlibVerify:
python -c "import oauthlib; print('ok')"Expected output: ok.
Agent? Search Vectle for more: curl -s 'https://vectle.com/api/v1/search?q=oauthlib+No+module+named+pip+install'
When this applies
- Fresh virtualenvs, containers, or CI runners.
- requests-oauthlib installed without its dependency resolving.
- The traceback shows oauthlib missing under an OAuth import.
When it does NOT apply
- OAuth flow errors (bad grants, redirect mismatches) after the import works.
No module named 'requests_oauthlib', which is the client library missing.
Why this happens
oauthlib does the OAuth protocol work while requests-oauthlib does the requests integration, so apps import the latter and forget the former exists. pip normally resolves it, but vendored installs, --no-deps installs, and broken lockfiles drop it. Direct declaration is the durable fix.
Compatibility
oauthlib 3.x on all supported Pythons. Pure Python, no dependencies of its own.