1

Whenever I try to plot anything on Spyder (ver4.0.1 python ver3.7.6 Ipython ver7.12.0), my script runs fine, however the pyplot.show freezes up in a white screen and refuses to display anything. For example in the screen shot below the print parameter line of code occurs after the plot function but still outputs to the command screen. Whenever I try closing the frozen plot display my kernel also crashes and I need to reboot it.

Initial frozen plot after running the script: Initial frozen plot after running the script

Post force close - kernel crash: Post force close - kernel crash

I've tried testing my pyplot module and it seems to me that whenever I run any pyplot commands the frozen display plot appears and crashes my kernel. This includes the code below:

from matplotlib import pyplot as plt

plt.figure()
#plt.title('test')
plt.plot(x,y)
plt.show()

I ran it line by line and as soon as it hit plt.figure it outputted the white screen, as well as plt.anything for that matter in any order - it just defaults to the white screen.

Weird thing is it just outputs and is frozen and you can't interact with it, but the rest of Spyder runs fine if you just ignore it in the corner.

I tried reinstalling the modules, spyder and Anaconda3 itself multiple times but none of the reinstalls helped solve the problem. I hope that people here have an idea on how to fix this as I've spent all day but gotten nowhere :(

machnic
  • 2,304
  • 2
  • 17
  • 21
Glen Chen
  • 11
  • 3
  • What Matplotlib backend are you using? – Carlos Cordoba Apr 01 '20 at 16:25
  • Ok, I just saw that you're using Tk from your second screenshot. It seems there's a bug in `ipykernel` for that backend, so you can't use it at the moment. Please use other backends in the meantime. – Carlos Cordoba Apr 01 '20 at 16:27
  • Hi @CarlosCordoba sorry for not getting back, notifications didn't come up for me. How would i switch to a different backend as i'm quite new with python, to solve the problem? Found this link ---> https://stackoverflow.com/questions/3285193/how-to-change-backends-in-matplotlib-python <---- but dk how i should be using it to colve my problem :( – Glen Chen Apr 08 '20 at 04:15
  • Please go to `Tools > Preferences > IPython console > Graphics > Backend`, select "Automatic" there and restart Spyder. – Carlos Cordoba Apr 08 '20 at 17:54

1 Answers1

0

I had exactly the same problem. Changing the backend did not help but I had matplotlib installed via pip. I could solve the problem by uninstalling matplotlib with pip uninstall matplotlib and re-install it using the anaconda navigator.

SariO
  • 429
  • 3
  • 16