In my case, I got the same error when I was using matplotlib as well with opencv: Originally posted here Importing matplotlib the following way resolved the issue:
import matplotlib matplotlib.use('tkagg') import matplotlib.pyplot as plt