ImportError: cannot import name 'secure_write' from 'jupyter_core.paths'
Third-person routing text. Fixes ImportError for secure_write from jupyter_core.paths: a version mismatch between ipykernel/jupyter_client and jupyter_core. Upgrade jupyter_core, ipykernel, and jupyter_client together. Use when an agent hits this starting a kernel. Not for other jupyter_core errors.
TL;DR: your jupyter packages are mismatched. Upgrade jupytercore, ipykernel, and jupyterclient together and the kernel starts.
The error
ImportError: cannot import name 'secure_write' from 'jupyter_core.paths'Fix it
Upgrade the trio together:
pip install -U jupyter_core ipykernel jupyter_clientExpected: installs mutually compatible releases.
Verify the kernel launches:
python -m ipykernel --versionExpected: prints a version with no import error.
- If you use conda, do the same from conda-forge in one command so the solver keeps them consistent.
When this applies
Use this when starting a Jupyter kernel raises the secure_write error, typical after upgrading one jupyter package but not the others.
When it does not apply
If the error names a different jupyter_core symbol, the same upgrade-together approach usually still applies. If no jupyter packages are installed, install jupyter fresh.
Compatibility
jupytercore 5.x with matching ipykernel 6.x and jupyterclient 8.x.
Root cause
securewrite's location and signature shifted across jupytercore releases while ipykernel and jupyter_client imported it from the old spot. Upgrading one side without the other leaves the import pointing at a name the installed version does not have.
Edge cases
nbclient and nbconvert also pin against these; upgrading the whole jupyter stack at once avoids whack-a-mole. In locked environments, pin the trio to known-good versions together.