How does matplotlib know which backend to be supported on which OS?

I have matplotlib installed in windows10. When I see the matplotlib package I see the pyd file created for backend_agg and tkagg. Why did it only make a pyd file for tkinter backend ??

If you explicitly set a backend (via rcparam, env, %matplotlib or matplotlib.use) we try to import the dependencies we need (if we fail or fallback is controlled by rcParams['backend_fallback']). See for more details.

If you do not specify a backend via one of those methods the default backend is “auto” where we go through the backends in turn until we find one that imports. Something we have talked about (but not done) is to make the fallback list configurable (it seems like a good idea, but no one has asked for it yet).

I suspect that in your env you do not have the qt or gtk packages installed (and you are not on a mac) so the first backend that imports is Tk so you get tkagg as the auto-selected backend.

All of that said, the Agg backend and the tk backend are c-extensions on the Matplotlib side (for qt / gtk / wx we only have Python code that makes use of dependencies that do the c/c++ <-> Python wrapping) and it looks like the pyd files how extension modules are deployed on windows (on linux these show up as .so s).

@tacaswell, thank you so much for the reply. It has cleared my doubts