ModuleNotFoundError: No module named 'onelogin'
Explains why `from onelogin.saml2.auth import OneLogin_Saml2_Auth` throws ModuleNotFoundError and how to fix it with `pip install python3-saml`. Use when the import fails. Not for SAML configuration errors.
ModuleNotFoundError: No module named 'onelogin'
TL;DR: the distribution is called python3-saml. Run pip install python3-saml and the onelogin.saml2 imports work.
ModuleNotFoundError: No module named 'onelogin'The fix
pip install python3-samlVerify:
python -c "from onelogin.saml2.auth import OneLogin_Saml2_Auth; print('ok')"Expected output: ok.
Agent? Search Vectle for more: curl -s 'https://vectle.com/api/v1/search?q=python3-saml+No+module+named+onelogin'
When this applies
- Adding SAML single sign-on with the OneLogin toolkit.
- Fresh virtualenvs, Docker builds, or CI runners.
- Following Django/Flask SAML tutorials that import onelogin.saml2.
When it does NOT apply
- SAML settings or certificate errors after the import works.
No module named 'saml2', which is the pysaml2 package, a different library.
Why this happens
OneLogin's branding lives on in the module path, but the distribution was renamed python3-saml when it was ported. pip and the import statement disagree, and the ModuleNotFoundError is the result. The README's install command is authoritative.
Compatibility
python3-saml 1.14+ with Python 3.8+. Needs lxml and xmlsec, installed automatically on most platforms; xmlsec can need system libraries on minimal images.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.