How To Setup Jupyter Notebook In Conda Environment And Install Kernel

Patrick Loeber
Thumbnail image of the post.

Whenever I setup a new conda environment and want to use a jupyter notebook with the correct Kernel for this environment, I find myself googling this over and over again. So I finally decided to list the necessary commands here.

How To Install Jupyter Notebook And The Kernel In Your Conda Environment

Assuming your conda-env is named ml, it is as simple as:

$ conda activate ml (ml) $ conda install ipykernel (ml) $ ipython kernel install --user --name=<any_name_for_kernel> (ml) $ conda deactivate

conda install ipykernel installs all dependencies needed to use jupyter.

ipython kernel install --user --name=<any_name_for_kernel> installs the kernel for this environment. I usually use the same kernel name as the environment name here (i.e. ml in this example).

Source: Stackoverflow.

How To Remove/Uninstall a Kernel Again

Run jupyter kernelspec list to get the paths of all your kernels.

$ jupyter kernelspec list

Then simply uninstall your unwanted-kernel:

$ jupyter kernelspec uninstall unwanted-kernel

Source: Stackoverflow.

I hope this saves someone else some time as well 😊.

If this is helpful, you might also like my Anaconda Basics Tutorial.

FREE VS Code / PyCharm Extensions I Use

✅ Write cleaner code with Sourcery, instant refactoring suggestions: Link *

* This is an affiliate link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you! 🙏

Check out my Courses