The Error

Notebook kernel not found. Cannot execute cell.

The Fix

# Install ipykernel in your current Python environment
pip install ipykernel

# Register the kernel so Jupyter can find it
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

Why This Works

Claude Code’s NotebookEdit tool requires a matching Jupyter kernel to execute cells. The kernel specification maps a name (stored in the notebook metadata) to an actual Python environment. When the kernel name in the .ipynb file references an environment that is not registered on the current machine, execution fails. Installing and registering ipykernel creates that mapping.

If That Doesn’t Work

# Check what kernels are available
jupyter kernelspec list

# Update the notebook metadata to use an existing kernel
python -c "
import json
with open('notebook.ipynb', 'r') as f:
    nb = json.load(f)
nb['metadata']['kernelspec']['name'] = 'python3'
nb['metadata']['kernelspec']['display_name'] = 'Python 3'
with open('notebook.ipynb', 'w') as f:
    json.dump(nb, f, indent=1)
"

This rewrites the notebook to reference the default python3 kernel that most Jupyter installations provide.

Prevention

Add to your CLAUDE.md:

Before editing Jupyter notebooks, verify the kernel exists with `jupyter kernelspec list`. Use the standard 'python3' kernel name in notebook metadata for portability across environments.