Using matplotlib * without * TCL

What the title says. Is there a way to use the matplotlib library without installing TCL? Please do not tell me to bite the bullet and install TCL. I know how to do this, but for my own (maybe stupid) reasons why I don't want to.

I do not need to display graphics, I only want to display them in png. I tried different things (using different backends, etc.), but matplotlib always wanted to find tcl to work :( Why is TCL so important for matplotlib?

Also note that I use windows - I installed everything that may be required (numpy, pandas, matplotlib) using pip.

@Gerrit's solution is correct (I tried to change the backends, but I did it after loading pyplot - it is important that you need to change the backend immediately after creating matplotlib). Here is a small example of its use:

import matplotlib
matplotlib.use ('Agg')
import matplotlib.pyplot as plt

fig, ax = plt.subplots (nrows = 1, ncols = 1)
ax.plot ([0,1,2], [10,20,3])

fig.savefig ('foo.png')
plt.close (fig)

This will exit the file named 'foo.png' without using TCL \ o /

+4
source share
1 answer

Immediately after loading matplotlib, enter

matplotlib.use('Agg')

Do this before downloading pyplot, if at all possible.

Matplotlib TkAgg, Tcl. , Agg . WX QTAgg, .

matplotlibrc:

backend : Agg

. Matplotlib " ?".

+9

All Articles