Skip to content

Change Kernel for Jupyter Notebook

KY Lee ( Ken ) edited this page Mar 25, 2021 · 1 revision

Sometimes, one might wants to change the kernel in the Jupyter Notebook. This guide shows how one can do so.

Step-by-step Guide

  1. One important requirement for this Wiki to works is for both the environments to have ipykernel installed. You can do so by

source activate myenv
conda install ipykernel

  1. Go to the first environment and install a Python (myenv) kernel in it with the following:

source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

image

  1. Then go to the second environment and install another kernel:

source activate other-env
python -m ipykernel install --user --name other-env --display-name "Python (other-env)"

image

Now if you open Jupyter Notebook, you will be able to change the kernel by following the image below.
image

You can double whether the right kernel is selected by using the following code. It will print out the environment that the kernel is operating on.
import sys
sys.executable


image

Reference https://ipython.readthedocs.io/en/stable/install/kernel_install.html

Clone this wiki locally