Kernel Error – Jupyter Notebook

Kernel Error
1 0
Read Time:2 Minute, 30 Second

All the data science enthusiasts must be aware of Anaconda Navigator which is one of the most useful tools for data science projects as it comes up with all the useful packages.
I recently started using it again and after installing it when I opened a Python 3 file, I saw a red box with Kernel Error written in it. I googled for a solution and realized that I have not set the virtual environment for it.

Now that I have solved this issue, following the tradition of this blog page, I am sharing the solution – “how to get rid of this kernel error”. So let’s get started.

First of all, you need to open the Anaconda Prompt, which is a terminal that gives you to access the back-end of this tool. To open this, go to the search bar and type Anaconda Prompt and run it as Administrator.

A black screen will appear with the location of the base directory on it. Here (base) is the base environment and c:\WINDOWS\system32 is the base directory.

We have to switch to the desired directory where we want to do our development. I use my E: drive for development, you choose according to your convenience. I have created a new folder named Data Science and within that is a machine folder. I will be using this path to install my kernel and further development.

If you will type jupyter notebook on the terminal and run it then you will not find any environment except Python 3 and if you open a python 3 file you will get the kernel error.

So exit from the front end. Press CTRL + C in your Anaconda Prompt to exit. Now we will create our virtual environment and to create that use the below code.

conda create -n <your environment name>

After creating, activate it with the below mentioned code.

conda activate <your environment name>

You will notice that after activating, the environment changes from (base) to (ankit).
Next, we have to install the kernel [ipykernel]. Install it using the conda command mentioned below.

conda install ipykernel

It will take a few minutes to download and install ipykernel and its dependencies. Once it is done the only thing left is to add this kernel with our virtual environment.

python -m ipykernel install --user --name myenv --display-name "<your environment name>"

We are done with all the processes and you can install the libraries you want in this environment by using the conda command. Some of them are shown below.

conda install numpy
conda install pandas
conda install matplotlib

Now when you will open the jupyter notebook, you will find your environment name there and you can use it to write your coding or data science projects.

If you find this post helpful then LIKE it and FOLLOW my blog.

Will post more such interesting and helpful content related to Business Intelligence and Data Science.

Thank you.

Happy
Happy
100 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

16 thoughts on “Kernel Error – Jupyter Notebook

  1. Thank you so much! This article was extremely helpful to be able to have a virtual environment that works. I have a question though…
    I recently uninstalled Anaconda and everything that came with it, following exactly its documentation. When I reinstalled it, that’s when I had this kernel error. What could I have possibly done wrong? Before uninstalling Anaconda, the “Python 3” option at Jupyter Notebook was working just fine.
    Thanks!

  2. And for R kernel? What would be the code line for adding R kernel to our virtual environment? I have it added to my jupyter lab but it’s not working and I think your solution would work for it too. Thank you!

  3. Hi, i followed all the steps you showed in above steps but still the error is not fixed in my case. I am using Windows 11 Pro version. Can you please suggest me, how to get rid of this problem.

Leave a Reply

Your email address will not be published. Required fields are marked *