ImportError: cannot import name 'passwd' from 'IPython.lib'
Third-person routing text. Fixes ImportError for passwd from IPython.lib: IPython removed it (it moved to notebook.auth). Use notebook.auth.passwd instead, or upgrade the tooling that does the old import. Use when an agent hits this generating a jupyter password hash. Not for other IPython.lib removals.
TL;DR: IPython removed passwd from IPython.lib. Import it from notebook.auth instead.
The error
ImportError: cannot import name 'passwd' from 'IPython.lib'Fix it
- Replace the import:
from notebook.auth import passwdExpected: no import error.
- For a version-proof script, gate it:
try:
from notebook.auth import passwd
except ImportError:
from IPython.lib import passwd- Verify:
python -c "from notebook.auth import passwd; print(passwd('x')[:6])"Expected: prints the start of a hash like argon2:.
When this applies
Use this when a setup script does from IPython.lib import passwd on modern IPython.
When it does not apply
If the error names a different IPython.lib member, look up its new home. If notebook is not installed, install it; notebook.auth is where the function lives now.
Compatibility
Modern IPython (7+) with notebook installed. Very new jupyterserver-based setups moved it again to jupyterserver.auth; check if notebook.auth is absent.
Root cause
passwd generated the password hash for the classic notebook server. When auth moved with the server code, IPython dropped its copy, and scripts importing the old path break.
Edge cases
If you are hashing passwords for jupyterserver (not classic notebook), import from jupyterserver.auth instead. Never log or print full password hashes; they are secrets.
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.