# ModuleNotFoundError: No module named 'saml2'

TL;DR: the distribution is called pysaml2. Run `pip install pysaml2` and the saml2 imports work.

```text
ModuleNotFoundError: No module named 'saml2'
```

## The fix

```
pip install pysaml2
```

Verify:
```
python -c "from saml2 import BINDING_HTTP_REDIRECT; print('ok')"
```
Expected output: ok.

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

## When this applies
- Code importing from the top-level `saml2` package.
- Fresh virtualenvs, Docker builds, or CI runners.
- Choosing between the two Python SAML libraries.

## When it does NOT apply
- `No module named 'onelogin'`, which is python3-saml, the other SAML library.
- SAML metadata or binding errors after the import works.

## Why this happens
The `saml2` name was too generic to claim on PyPI, so the distribution took the `py` prefix while the module kept the clean name. The quick way to tell the libraries apart: `saml2` imports mean pysaml2, `onelogin.saml2` imports mean python3-saml.

## Compatibility
pysaml2 7.x with Python 3.8+. Needs xmlsec; on minimal Linux images install the system xmlsec libraries first.