How to solve the no module named Seaborn error in Python?

Today’s tutorial is dedicated to solving import errors related to the Seaborn data visualization module.

Module not found errors are typically ubiquitous when starting to work with a new Python library (think Pandas, numpy, requests, Matplotlib and others) in your development environment, or when you are installing a new environment from scratch either manually or using a predefined distribution like Anaconda.

Solving the Seaborn module not found

Why is Seaborn not working in Jupyter or other data Visualization environments? The typical reason for this error is that the Seaborn package is simply not installed in your environment.

Before starting your troubleshooting, you might want to use the command pip list to find out the packages that are installed.

Seaborn not found error messages in Jupyter and Spyder

Below you can find a screenshot of the error message that you will get in Jupyter Notebook / Labs.

And in Spyder:

You’ll encounter similar errors in PyCharm or other Python Integrated Development Environments. In this post we’ll show how to add Seaborn to Jupyer and other IDEs.

Fix Seaborn import errors in Anaconda or MiniConda

If you are using the Anaconda or MiniConda distributions , proceed as following:

  • Save your work.
  • Close your Jupyter notebook / Dev environment.
  • Open your Anaconda Command Prompt.
  • Type: conda activate <full os path to your Conda environment>. For example:
conda activate c:\envs\Python395
  • Hit Enter.
  • Then type pip install seaborn
  • The seaborn package will be collected from the Python package repository by the Python Package installer (pip) and installed in your operating system.
  • Once successfully installed you’ll receive a message in your Mini-Conda prompt.
  • Type Exit and hit enter to exit the Minconda prompt.
  • Reopen your Notebook or Python Editor and import seaborn, by typing
import seaborn as sns

Note for Anaconda users: You can leverage the Anaconda Environment Manager that provides a graphical user interface to maintain your environment, including package installation and removal.

Use Pip install to fix Seaborn module not found error and add in to Jupyter

If you are using a standalone installation or virtual environments that you have manually configured using pip, you can use your operating system command prompt / terminal directly:

  • Save your work.
  • Exit your Jupyter Notebook or IDE.
  • Open the Windows command prompt (cmd).
  • In Windows type cd <full_path to your Python environment> – for example:
cd c:\My_Python_Env
  • Then type:
pip install seaborn
  • Hit Enter.
  • After Seaborn is installed, type exit and hit Enter.
  • Reopen your notebook and import Seaborn by typing:
import seaborn as sns

Note: in case that the above instructions didn’t solve your SNS not found error message, make sure to close Jupyter or your Python IDE (VSCode, Spyder) and start it again. If this doesn’t help save your work and restart your computer.

Happy data visualization 🙂