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 error

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. Use conda or the pip Package Manager to install Seaborn and then import it into your Python development environment such as Jupyter and VSCode.

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 Jupyter 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 Miniconda prompt.
  • Reopen your Notebook or Python Development editor and import Seaborn, by typing:
import seaborn as sns

Note for Anaconda users: You can use the Anaconda Environment Manager to fix import errors. Anaconda provides a very intuitive graphical user interface to maintain your environment, including package installation and removal.

Pip install Seaborn to fix module not found errors in 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.

Finding installed packages in your Development Environment

Before starting troubleshooting any issues related to third party Python packages, you might want to use the command pip list to find out which packages are installed in your system.

Proceed as following:

  • Open the command prompt or Anaconda Prompt
  • If using Anaconda, activate your environment.
  • Type the following command
pip list

    The list of 3rd party packages in your environment will be displayed:

    Happy data visualization 🙂