My Matplotlib backend keeps reverting to TkAgg
. This is a problem because in the Windows Subsystem for Linux (WSL), you can't do GUI stuff, and so I get the error
TclError: no display name and no $DISPLAY environment variable
I've tried adding a matplotlibrc
file to /home/<user>/.config/matplotlib
(in the Windows filesystem, this is C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib
).
My matplotlibrc
looks like this
backend : Agg
However, if I do this
$ cd /home/<user>/.config/matplotlib
$ ls -A
nothing shows up.
When I try
$ python
>>> import matplotlib
>>> matplotlib.get_backend()
'TkAgg'
so clearly it's not setting the backend to Agg
. Why not?
Update:
I've figured out that putting backend : Agg
in C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib\matplotlibrc
changes the backend in Windows Python only, leaving Linux Python as TkAgg
. Which is odd, because Windows Python should only be using C:\Users\<user>\AppData\Local\Enthought\Canopy\User\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
, right?
Copyright Notice:Content Author:「binaryfunt」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40747104/set-matplotlib-backend-when-using-windows-subsystem-for-linux