5

Screenshot of error

Hi, I'm taking a machine learning course on udemy and im trying to run the following:

%matplotlib inline
import matplotlib.pyplot as plt

The issue is that once I run this, it kills the kernel and the message shown in the picture is the only thing that comes out.

I'm new to this and I just want to move forward with the course but this is holding me back.

TIA

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Carlos Ortiz
  • 51
  • 1
  • 4
  • `%matplotlib inline` should already include `import matplotlib.pyplot as plt`. What happens when you run each of those commands separately? Which one is triggering the restart? Does this happen with a freshly-loaded kernel and an empty Jupyter notebook? – MattDMo Sep 05 '21 at 21:51
  • the import line is what causes it, and yes even with a new notebook it happens – Carlos Ortiz Sep 05 '21 at 21:56
  • Does your code otherwise work fine without the import statement, even if it uses `plt`? – MattDMo Sep 05 '21 at 21:57
  • Still, even if it does, I would recommend force uninstalling and reinstalling `matplotlib`. – MattDMo Sep 05 '21 at 21:58
  • No, it doesnt. I get an error code saying "plt" is not defined – Carlos Ortiz Sep 05 '21 at 21:58
  • How can i do the uninstalling and installing? – Carlos Ortiz Sep 05 '21 at 21:59
  • `pip install --force-reinstall matplotlib` should do the trick. – MattDMo Sep 05 '21 at 22:03
  • Just did it and it still happens – Carlos Ortiz Sep 05 '21 at 22:07
  • Darn. How familiar are you with the command line (Terminal.app)? Have you configured a `matplotlibrc` file or `jupyter_config.py` or any of those? – MattDMo Sep 05 '21 at 22:14
  • uhhh nope. I just installed python a 3 and anaconda and thats it. Chcecked on anaconda and matplotlib is installed. I can work with the command line, i would just need the steps and commands and I would be able to do it – Carlos Ortiz Sep 05 '21 at 22:17
  • OK, make sure you've completely closed out of your Jupyter notebooks and shut down all the running kernels. Then, in Terminal, type `cd` and hit Enter. Next, enter each of these commands one at a time, *exactly* as they are here: 1) `rm -rf .matplotlib` 2) `rm -rf .ipython` 3) `rm -rf .jupyter` You may get errors after some of them saying it doesn't exist, you may not. Then, restart your Jupyter notebook and see if the behavior still happens. – MattDMo Sep 05 '21 at 22:27
  • Are you using an anaconda distribution? – Trenton McKinney Sep 05 '21 at 23:38
  • Quick update. I had to completely uninstall all the anaconda files and software and reinstall it. I installed the terminal version of anaconda instead of the graphic one and everything works fine now. Thanks yall. – Carlos Ortiz Sep 07 '21 at 01:59

1 Answers1

3

The problem was solved for me by running conda install freetype=2.10.4, as reported on this GitHub issue

Jondiedoop
  • 3,303
  • 9
  • 24