It can be done by either editing the kernel.json file or registering new kernel with changed kernel.json file.
kernel.json contains argv attribute that essentially a command to run python.
{
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
Editing existing kernel.json file
You can find your kernel.json by running:
→ jupyter kernelspec list
Available kernels:
python3 /home/user/.local/share/virtualenvs/jupyter/share/jupyter/kernels/python3
You can edit it to your liking.
Insalling custom kernel
You can use the command from previous solution to find the existing kernel.json
then install the new kernel:
jupyter kernelspec install /home/user/.local/share/virtualenvs/jupyter/share/jupyter/kernels/python3 --name=python3_custom --user
Find your python3_custom location with
jupyter kernelspec list
and edit the kernel.json there
Jupyterlab kernel docs
registering kernels in ipython/jupyter notebook - kernel.json
jupyter -notebookapply to the Python session that runs the server, not the kernel that processes the notebook code.