Lab error matplotlib widget

I am seeing this error for the %matplotlib widget in my Jupyter notebook. How do I solve it? and there is no error if the %matplotlib widget is absent.

are you running the course assignment on your local Jupyter? have you downloaded all the necessary files required to do the assignment? or you have just downloaded the assignment notebook??

yes local jupyter,
I downloaded the lab files of week 1 , course 1 and I was practicing the 3rd lab of week 1 and I also copied those files in the same directory where my jupyter files are.

Hello farhana,

can you mention the lab name, just to be clear if you running an optional ungraded lab?

I think you are running Cost function lab


In this lab we will make use of:

  • NumPy, a popular library for scientific computing
  • Matplotlib, a popular library for plotting data
  • local plotting routines in the file in the local directory

So make sure your Jupyter lab has access to the required lib files required to run this assignment


yes cost function

i do have all of 3

Hi Deepti,
Is it okay to use %matplotlib notebook instead of %matplotlib widget ?

Hello farhana

The use %matlplotlib widget generates an ipywidget that renders plots in a control. Multiple plots and zooming are supported.

I am not sure by %matplotlip notebook do you mean %matplotlib inline?? inline renders you images as PNG files which is not the requirement for this assignment.

The requirement of %matplotlib widget will be required throughout the assignment as we are going to check cost function intuition which again uses these widget while plotting.

Can you share that whole error message you got in text form here.



I did some digging and found one needs to have the following packages to create a %matplotlib widget

Python 3.8.1
matplotlib 3.1.3
NumPy 1.18.1
ipywidgets 7.5.1
ipympl 0.4.1

Check if your Jupyter has all these module