SerializationError: Cannot serialize return value from function

What I’m trying to do:
I am trying to receive the Matplotlib object in anvil UI. And I getting the following error -
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize <class ‘module’> object at msg[‘response’][0]

What I’ve tried and what’s not working:

plot = anvil.server.call(‘Anvil_Income_Graph’,self.startdate.date,self.enddate.date,self.dpdnIndividual.selected_value,self.dpdnIncomeType.selected_value)

I am expecting to have plot as Matplotlib object.

You’ll have to convert the plot to a png.

If you check out the source code for this example you’ll see that anvil provides a module to convert the matplot plot to a media object which you can then return and display in an image component.

And here’s the api reference for that function.

Anvil Docs | anvil.mpl_util

1 Like

Thanks for the link and it helped.