I believe what you are looking for is how to change the Kernel you are running. If you go to the Kernel menu in Jupyter, you will see the option to change kernels.
If you want to add a new kernel from a conda environment, terminate jupyter, activate the environment you want to add a kernel for, and then run this command (requires conda install ipykernel
-- thx @shad):
python -m ipykernel install --user --name <kernel_name> --display-name "<Name_to_display>"
Make sure to replace <kernel_name>
and <Name_to_display>
to the name of your environment. Also, this requires you to conda install ipykernel
(thanks @shad).
Once you installed the kernel, you can change to it through the above menu and even through this code snippet from a Jupyter cell:
%%javascript
Jupyter.notebook.session.restart({kernel_name: '<kernel_name>'})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…