1👍
✅
I had the same problem, and I find out that there was a problem with the backend that matplotlib was using, to solve this, the recommended backend is Agg, and you should set this up before importing pyplot:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as pyplot
You can find more documentation here.
Source:stackexchange.com