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.
Register a venv as a kernel
Section titled “Register a venv as a kernel”Typical pattern with a project-local venv:
cd /home/$USER/projects/my_ml_projectsource .venv/bin/activatepip install ipykernelpython -m ipykernel install --user --name=my_ml_projectList kernels
Section titled “List kernels”jupyter kernelspec list # names + pathsjupyter kernelspec list --json # full details including argvInspect a kernel’s Python
Section titled “Inspect a kernel’s Python”Each kernel stores its Python path as an absolute path in kernel.json. Read it to verify which interpreter the kernel actually launches.
cat ~/.local/share/jupyter/kernels/finlab-backend/kernel.jsonThe argv field is the launch command:
"argv": [ "/full/path/to/project/.venv/bin/python", "-Xfrozen_modules=off", "-m", "ipykernel_launcher", "-f", "{connection_file}"]Check whether that Python still exists:
ls -l "/full/path/to/project/.venv/bin/python"
# or as a boolean checktest -x "/full/path/to/project/.venv/bin/python" && echo "exists" || echo "missing"Fix a kernel
Section titled “Fix a kernel”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.
jupyter kernelspec uninstall old-kernel-name
cd /path/to/current/projectsource .venv/bin/activatepip install ipykernelpython -m ipykernel install --user --name=old-kernel-name