Skip to content

Register Jupyter Kernels

In this case we assume no jupyter is availble in the global environment, instead we will use the venv to install the jupyter and manage the operations after venv activation.

Typical pattern with a project-local venv:

Terminal window
cd /home/$USER/projects/my_ml_project
source .venv/bin/activate
pip install ipykernel
python -m ipykernel install --user --name=my_ml_project
Terminal window
jupyter kernelspec list # names + paths
jupyter kernelspec list --json # full details including argv

Each kernel stores its Python path as an absolute path in kernel.json. Read it to verify which interpreter the kernel actually launches.

Terminal window
cat ~/.local/share/jupyter/kernels/finlab-backend/kernel.json

The argv field is the launch command:

Terminal window
"argv": [
"/full/path/to/project/.venv/bin/python",
"-Xfrozen_modules=off",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
]

Check whether that Python still exists:

Terminal window
ls -l "/full/path/to/project/.venv/bin/python"
# or as a boolean check
test -x "/full/path/to/project/.venv/bin/python" && echo "exists" || echo "missing"

A kernel will be no longer availble if its registered Python path no longer available in case like after renaming a project folder or recreating a venv. The fix is to uninstall and register again from the new location, keeping the same –name so existing notebooks that reference the kernel keep working.

Terminal window
jupyter kernelspec uninstall old-kernel-name
cd /path/to/current/project
source .venv/bin/activate
pip install ipykernel
python -m ipykernel install --user --name=old-kernel-name