How to import Seaborn in Jupiter Notebook

Hello Guys,
Can someone explain me how to install Seaborn in Jupiter Notebook?

Thanks

pesako8656

Assuming you meant the question in your post text and not the title…

It depends on what you are using as your primary package manager for your Python and Jupyter ecosystem.

If you using Anaconda/condam then type in a notebook cell with an active Python kernel:

%conda install -c conda-forge seaborn

Based on here and here.

If talk of ‘Anaconda/conda’ doesn’t ring any bells for you, then you can safely use the default package handler that comes with Python, assuming you installed it already. (If Jupyter is working with a Python kernel, it is there already somewhere.) So run in a cell the following:

%pip install seaborn

Based on here.
The latter option, with %pip install will even work in JupyterLite.

It is always best to restart the kernel after either of those magic install commands.
Learn more about the magic install commands added in 2019 to insure when running an install command in the running .ipynb files that the installation occurs in the environment where the kernel is running, here.


To address your post’s title…

After installing successfully, you would be able import seaborn now. It is generally done this way.

import seaborn as sns

See the documentation’s ’ An introduction to seaborn’ for an example import. (Be aware that in JupyterLite, the sns.load_dataset() steps won’t work as in the documentation; you can go and get the data directly from the repository with the example datasets here and comment out the corresponding line.)

1 Like
%pip install seaborn

Works perfectly, thank you soo much.

1 Like