Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected

I am new to pandas_profiling and getting ImportError while importing it. Please help.

import numpy as np
import pandas as pd
import pandas_profiling
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
import seaborn as sns

After executing the above code in jupyter notebook, I am getting the following error.

ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.

> python --version
Python 3.7.3

> pip list | grep -E "matplotlib|pandas"
matplotlib 3.2.0
pandas 0.25.3
pandas-profiling 2.5.3

like image 397
Shilpa Deshmukh Avatar asked Apr 01 '20 18:04

Shilpa Deshmukh


People also ask

Which module of matplotlib library is required for plotting of graph?

In Matplotlib, Bar Graphs are made using plt. plot() with plt. bar() and voila! We get a bar plot.

Why is matplotlib not working on Vscode?

This is because Microsoft C++Build Tools hasn't been installed in your computer. In order to run matplotlib or a similar interactive interface in Microsoft for Python, Build Tools is needed, not only Microsoft C++ Redistributable.

How do I install matplotlib?

If you are using the Python version that comes with your Linux distribution, you can install Matplotlib via your package manager, e.g.: Debian / Ubuntu: sudo apt-get install python3-matplotlib. Fedora: sudo dnf install python3-matplotlib. Red Hat: sudo yum install python3-matplotlib.

How do I download matplotlib in Vscode?

Install matplotlib by entering its name into the search field and then selecting the Run command: pip install matplotlib option. Running the command will install matplotlib , and any packages it depends on (in this case that includes numpy ). Choose the Packages tab. Consent to elevation if prompted to do so.


1 Answers

I don't know the actual reason but I restarted the kernel and it is working.

Before restarting the kernel I executed following commands:

conda install -c anaconda pandas-profiling

like image 195
Shilpa Deshmukh Avatar answered Oct 25 '22 14:10

Shilpa Deshmukh