Matplotlib kills kernel on Jupyter - python

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

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

Related

Matplotlib does not show plot in PyCharm on Mac

I am using PyCharm on my MacBook to code and now I wanted to make a simple plot. When I run the file via the usual 'Run' command (do not know what it is called), it nicely shows my plots, but when I run the file in the Python console (which I find more convenient because you can access your variables) it does not show anything. On the other hand, when I just type it in the Python console afterwards, it does work.
I have read some things about backends and other 'solutions' as I am apparently not the only one with this issue. Mine says macosx and gives the command: "Backend MacOSX is interactive backend. Turning interactive mode on." after running the file in the Python console. I tried changing the backend:
import matplotlib
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
but that does not work (no plot pops up). And yes, I use plt.show() after my plotting section :)
I also tried with 'QtAgg' but then I get: "ImportError: Failed to import any qt binding"
Now I am completely new to this backends stuff (I think it has to do with this), so I could really use some clear directions on how I can solve this issue.
Thanks in advance!
I am not sure we can solve this bug with some adjustment. I think you need to fresh start. I suggest you to start a new clean venv and install a new matplotlib there.

Error : "The kernel appears to have died. It will restart automatically."

I am facing an error which I do not know how to fix. I'm trying to get this piece of code to work on windows but I have this error appearing
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.plot()
Error: "The kernel appears to have died. It will restart automatically."
I just had the same error message appear while using Jupyter notebook. Based on what I read, I think it's suggested to reinstall pandas, NumPy and matplotlib (other libraries if necessary) and see if that works.
I had several other issues, so I reinstalled the Anaconda navigator.
You can just use py script instead of Jupyter but if you wanna use Jupyter try either reinstalling NumPy or update.
pip install -U numpy

Kernel appears to have died - Jupyter notebook python matplotlib

I am trying to learn charting in Python and keep getting this message in Jupyter:
The kernel appears to have died. It will restart automatically.
My other basic programs are working, so it looks like using Matplotlib is causing this problem. Any thoughts on how to resolve this?
import matplotlib.pyplot as plt
plt.plot()
plt.show()
if you don't solve the problem after using method above, you can try this:
import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
add two lines of codes in your python code. This mothed is also useful to pycharm.
I try the solution of this video, based on this post, and it worked for me:
Run Anaconda Prompt as administrator
conda install --yes freetype=2.10.4
I did the following :
conda install --yes freetype=2.10.4
it works. Great!

Matplotlib doesn't show plots on Mac; plt.show() hangs on 'MacOSX' backend

As of late, I can't get my Matplotlib plots to show up. I have a very simple script:
import matplotlib.pyplot as plt
plt.plot([1,2,3])
but nothing ever shows up. If I include the line
plt.show()
then my Python process hangs.
In my ~/.config/matplotlib/matplotlibrc file I have
backend : MacOSX
interactive : True
I'm a little embarrassed to ask this question. I've been a Matplotlib user for many years and have never had this problem. I don't know where to begin to fix this problem. Help!
I'm using Matplotlib 2.0.0 with Python 3.5.2 from Anaconda.
The answer, as pointed out by #ImportanceOfBeingErnest is that the backend configuration for me wasn't working. I'm not sure if I need to install some additional libraries or not. I decided not to use the MacOSX backend and used the Qt5Agg backend. This worked just fine and I didn't have to install any new libraries.
I've just remove the line
interactive: True
enter code here
from my ~/matplotlib/matplotlibrc. It works fine with only backend: MacOSX using the plt.show() command.

Plot Window Hangs or is Empty in Python

I am having trouble with plots in a Jupyter Notebook in Python 3.5 on Mac OSX. The following code will hang when executed:
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline
myfig = plt.plot(range(5))
plt.show()
If I restart the kernel and un-comment '%matplotlib inline', I do get plots to work inline. However, I'd like to be plotting in a separate window.
If I insert the following code at the beginning:
import matplotlib
matplotlib.use('Agg')
then restart the kernel and run, the code will not hang, but nothing will be plotted, no window opened.
Details:
Mac Book Pro running OSX El Capitan
Anaconda Python 3.5 in a Jupyter Notebook
backend is "MacOSX".
There is a post on GitHub mentioning that using Qt4Agg as backend worked...
If it is not available (and if you can), you might want to try using Hombrew to install Python (instead of Anaconda), Qt and/or Gtk with which you'll be able to use matplotlib without problem.

Categories

Resources