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.