Matplotlib draw error: Fail to allocate bitmap [How to Solve]

I used to draw many pictures with Matplotlib before. When I encountered this problem, I was out of memory

 

Solution:
Just add this at the beginning

import matplotlib
matplotlib.use("Agg")
 

Read More: