Matplotlib Runtime Error: main thread not in main loop

I am not trying to thread any processes but continue to run into this error all over the Django site. I've seen some other people ask this question, but they all try to use multiple threads.

It's on Django 1.11, Python 3.6, Matplotlib 2.0.0. I will also notice that this problem occurs on my mac, but not on my live Heroku server.

I am using Pyplot to create some renderings of model instances that users make, and I get this about half the time I try to run it:

Exception type: RuntimeError

Exception value: main thread is not in main loop

The last line of my code that gets run is just a call to plt.figure ()

Trace:

File "/Users/Mark/Desktop/Professional/FSC/water/WATER/hydrograph/views.py" in processData
  397.         hydroFigure = plt.figure()

File "/Users/Mark/Desktop/Professional/FSC/water/WATER/ENV/lib/python3.6/site-    packages/matplotlib/pyplot.py" in figure
  535.                                         **kwargs)

File "/Users/Mark/Desktop/Professional/FSC/water/WATER/ENV/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py" in new_figure_manager
  81.     return new_figure_manager_given_figure(num, figure)

File "/Users/Mark/Desktop/Professional/FSC/water/WATER/ENV/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py" in new_figure_manager_given_figure
  98.         icon_img = Tk.PhotoImage(file=icon_fname)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py" in __init__
  3539.         Image.__init__(self, 'photo', name, cnf, master, **kw)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py" in __init__
  3495.         self.tk.call(('image', 'create', imgtype, name,) + options)

Exception Type: RuntimeError at /hydrograph/
Exception Value: main thread is not in main loop

      

Any ideas on what I can do?

+3


source to share





All Articles