In this post we are going to take a look at adding Anaconda environment to Jupyter notebook.
Recently, I was working on a CSV file and wanted to work
with Pandas package for tabular data manipulation using Python.
The problem was even if I install Pandas package, I would
have to install other Data Science package as needed. But, the Anaconda environment
was already setup on my laptop, which I want to reuse.
Today, we will look into how to reuse the Anaconda
environment within the Jupyter Notebook.
There are 4 basic steps to be followed for adding the environment:
1. Create a conda environment
Go to Conda command prompt(Run in Admin mode)
Run the following command:
conda create –-name newenv
O/P:
What if there is an existing conda environment?
Go to Conda command prompt(No need for Admin mode)
Run the following command:
conda env list
O/P:
Since there was only one environment, only one entry was
displayed. ‘*’ indicates the current environment.
2. Activate the new or existing environment
Go to Conda command prompt(Run in Admin mode)
Run the following command:
conda activate base
O/P:
3. Install IPykernel
and the bellow command
Go to Conda command prompt(Run in Admin mode)
Run the following command:
conda install -c anaconda ipykernel – Note -c option specifies the location to download the package from Reference
O/P:
Package will be installed. Select option ‘y’ if asked
4. Run the Python -m
command to make the env available in Jupyter notebook
Note: The Env should be activated before running this
command
Go to Conda command prompt (Run in Admin mode)
Note: Python ipykernel options
Run the following command:
python -m ipykernel install -–user -–name=newenv
O/P:
5. Go to Jupyter notebook and refresh the Homepage to get
the new env
Last thoughts
Be mindful of the environment you select when creating a new
notebook in Jupyter. The environment name is listed at the top of the notebook.
My Opinion
The process to link the Anaconda environment to Jupyter is
quite easy. If at any point you do not understand the command use ‘--help’
option after the command to list more details.
Else, you can enclose the command in double inverted commas
and search on google for getting relevant results.
Thank you!!
Comments
Post a Comment