I am working on a project using Django
and Python
and I am trying to plot a simple graph using matplotlib
and I keep getting the error
uncaught exception of type NSException
Python
also crashed after that. I am using mac
if that helps.
Matplotlib version '3.1.0'
I have already tried using the most simple graphs but still the problem persists.
This is my code in the views.py file
def get_svg(request):
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='Sample')
ax.grid()
response = HttpResponse(content_type = 'image/png')
canvas = FigureCanvasAgg(fig)
canvas.print_png(response)
return response
This is the error message I get:
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
libc++abi.dylib: terminating with uncaught exception of type NSException
Aucun commentaire:
Enregistrer un commentaire