RuntimeError: The 'Agg' backend does not support show()
7 Dec 2025
1 min read
RuntimeError: The ‘Agg’ backend does not support show()
$ python -c "import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt; plt.show()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: The 'Agg' backend does not support show()
Why this happens
Agg renders to images only; it cannot display GUI windows.
Fix
Use savefig or switch to a GUI backend.
Wrong code
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.show()
Fixed code
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.savefig('plot.png')