在flask项目运行的过程中使用matplotlib画图报错并出现如下错误,错误主要为:
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘NSWindow drag regions should only be invalidated on the Main Thread!’
解决方法:
设置matplotlib在后台运行,不显示前台GUI
import matplotlib.pyplot as plt
plt.switch_backend('agg')