You open a notebook, press run, and Jupyter answers with a kernel error: the kernel died, failed to start, or simply shows a red “Kernel Error” banner with a traceback mentioning an environment you deleted months ago. The notebook file is almost never the problem. A kernel is just a Python environment that Jupyter launches behind the scenes, and the error means that launch went wrong. This guide explains what a kernel is, why it fails, and the sequence of fixes that resolves nearly every case.
Quick Answer
A Jupyter kernel error means Jupyter could not start or keep running the Python process behind your notebook. The most common cause is a missing or broken ipykernel package in the selected environment, or a kernel specification pointing at a deleted virtual environment. Fix it by installing ipykernel into the environment you intend to use — python -m pip install ipykernel — registering it with python -m ipykernel install --user --name myenv, and selecting that kernel in the notebook. Remove stale kernels with jupyter kernelspec remove name.
What a Kernel Actually Is
The kernel is a separate Python process that executes your cells and sends results back to the notebook interface. Jupyter itself is just the editor; the kernel is the engine. Each kernel is tied to one Python environment — the system Python, a conda environment, or a project virtual environment — and it can only import packages installed in that environment. This architecture explains the two classic confusions: the notebook opens fine but imports fail (the kernel’s environment lacks the package), and the kernel refuses to start at all (the environment it points to is broken or gone). Understanding this split turns kernel errors from mysteries into simple environment problems.
Fix 1: Install ipykernel Into the Right Environment
- Open a terminal and activate the environment you want the notebook to use. For a virtual environment, use its activation script; the prompt should show the environment name.
- Install the kernel machinery:
python -m pip install ipykernel. Usingpython -m pipguarantees the package lands in the interpreter you think it does. - Register the environment as a named kernel:
python -m ipykernel install --user --name myenv --display-name "Python (myenv)". Pick a name you will recognise in the notebook’s kernel menu. - Restart Jupyter completely, open your notebook, and choose Kernel → Change Kernel, then select your new entry.
- Run a test cell with
import sys; print(sys.executable). The printed path must be inside your environment. That confirms the notebook and your terminal finally agree. If you need the environment itself first, our walkthrough on creating a Python virtual environment covers the setup end to end.
Fix 2: Remove Kernel Specs That Point to Deleted Environments
Jupyter remembers kernels as small specification folders containing the exact path to a Python executable. When you delete a virtual environment, its spec survives and keeps offering a kernel that can never start. Clean them up:
- List what Jupyter knows:
jupyter kernelspec list. Note any names tied to projects or environments you deleted. - Remove the stale entries:
jupyter kernelspec remove oldname, confirming each removal. - Reopen the notebook and select a kernel that exists. The kernel error banner should be gone.
The official ipykernel documentation describes kernel installation and spec locations for each operating system in more detail.
Fix 3: When the Kernel Starts but Keeps Dying
A kernel that starts and then dies mid-run is a different animal. The usual causes are a cell that exhausts memory (loading a huge dataset into a small machine), a native library crash from a corrupted package install, or code that kills the process directly, such as os._exit(). Test with a fresh notebook containing one trivial cell. If the trivial notebook runs, binary-search your original notebook by running cells in order until the death returns, then inspect that cell’s memory use and imports. Reinstalling a suspect package with python -m pip install --force-reinstall packagename inside the kernel’s environment repairs corrupted binary wheels surprisingly often.
Fix 4: Check the Terminal Behind Jupyter
Jupyter prints its real diagnostics in the terminal or console where you launched it, not in the browser. When a kernel error banner appears, read that terminal: the traceback there usually names the exact missing file or package, turning guesswork into a direct repair. Launching Jupyter from an activated environment also ensures its default kernel is the one you expect.
Common Mistakes to Avoid
- Installing ipykernel into the wrong environment. pip and the kernel must serve the same interpreter. Always install with
python -m pipfrom the activated target environment. - Selecting “Python 3” and assuming it is your environment. The generic entry is Jupyter’s own default, often the system Python with none of your project packages.
- Deleting the notebook when the kernel fails. The
.ipynbfile is innocent. The environment behind the selected kernel is where the fault lives. - Ignoring the launching terminal. The browser banner is a summary; the terminal holds the full traceback that names the actual cause.
Preventing Kernel Problems in New Projects
Most kernel misery is set up on day one of a project and discovered on day thirty. A short routine at project start prevents nearly all of it. Create the project’s virtual environment first, before installing anything else. Install ipykernel into it immediately and register it under the project’s name, so the kernel you select in the first notebook session is unmistakably the right one. Add the project’s packages next, and note the environment’s name in the project’s README or a comment in the first notebook cell, so future you — or a teammate — knows which kernel the notebook expects. Finally, when a project ends or an environment is rebuilt, remove or re-register its kernel spec at the same moment you delete the folder, rather than leaving a ghost kernel behind for a future session to trip over. These five minutes of ceremony convert kernel selection from a recurring accident into a deliberate, documented choice, and kernel errors largely stop appearing in your work.
Conclusion
Kernel errors are environment errors in disguise. Install ipykernel into the environment you truly want, register it under a clear name, select it in the notebook, and delete stale specs pointing at environments that no longer exist. Verify with sys.executable inside a cell, and your notebooks will start reliably every time.
Frequently Asked Questions
Why does my notebook say “No module named…” when I installed the package?
Because the kernel’s environment is not the environment you installed into. This is the most common kernel confusion of all. Print sys.executable in a cell to see the kernel’s Python, then install the package with that exact interpreter’s pip, or switch the notebook to the kernel that matches your environment.
What is the difference between a kernel and an environment?
An environment is a Python installation with its own packages. A kernel is Jupyter’s registration of one environment as a runnable engine for notebooks. One environment can be registered as a kernel, and the ipykernel package inside the environment is what actually executes your cells.
How do I make a conda environment appear as a kernel?
Activate the conda environment, run python -m pip install ipykernel (or install it with conda), then python -m ipykernel install --user --name mycondaenv. Restart Jupyter and the environment appears in the kernel menu. Many conda setups also auto-discover environments with ipykernel installed.
The kernel died while running one specific cell. Why?
Most often that cell exhausted memory or triggered a crash in a compiled library. Check the data size the cell loads, watch system memory while it runs, and try the same operation in a plain Python script. If the script crashes identically, the problem is the code or the package, not Jupyter.
Can I have several kernels for different projects?
Yes, and that is the intended workflow. Register each project’s environment under its own name, and pick the matching kernel per notebook. Keeping kernels named after their projects prevents the wrong-environment import errors that plague beginners.


[…] ipykernel installed in the environment you plan to use. If kernels are new territory, our guide to fixing Jupyter kernel errors explains how kernels and environments […]