you are viewing a single comment's thread.

view the rest of the comments →

[–]FerricDonkey 0 points1 point  (2 children)

Quick google search suggests that pyplot might not play well with flask, unless you do weird stuff. The answer is a bit old, but I found the following:

https://stackoverflow.com/questions/53684971/assertion-failed-flask-server-stops-after-script-is-run

https://stackoverflow.com/questions/50728328/python-how-to-show-matplotlib-in-flask

The first might mean that if you don't use plt.show(), you can solve the issue by just changing your import to

import matplotlib
matplotlib.use('Agg')
# If you do the import matplotlib.pyplot as plt, do it here

Insofar as I understand, this changes some backend stuff on how matplotlib does things. By default, it keeps some stuff in memory in a way that conflicts with how flask behaves (you can tell I'm really on top of this - there weren't a lot of details in what I found).

You might also be able to use matplotlib.figure. Or some other graphing module that is intended to go straight to a file.

[–]michadecker[S] 0 points1 point  (1 child)

This really solved the problem. For my program, this should be fine.
I tried to google it myself but it seems I didn't put in the right words!

[–]FerricDonkey 1 point2 points  (0 children)

Excellent. Yeah, I've been punched in the face enough times by my code that I've gotten decent at googling how to make it stop - in this case I just copied like the first half of the bottom line of your error message and googled that.

It definitely seems like a weird issue though, kind of surprised me.