Set Matplotlib backend when using Windows Subsystem for Linux
NickName:binaryfunt Ask DateTime:2016-11-23T00:36:26

Set Matplotlib backend when using Windows Subsystem for Linux

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

More about “Set Matplotlib backend when using Windows Subsystem for Linux” related questions

Set Matplotlib backend when using Windows Subsystem for Linux

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 $

Show Detail

Show matplotlib plots in Ubuntu (Windows subsystem for Linux) - Python 3

I have followed the answer in the question linked below to the letter, and it works beautifully in Python 2, but I need this to work with Python 3 also. I can't seem to get matplotlib to play nicel...

Show Detail

Check if using Windows console in Vim while in Windows Subsystem for Linux?

I am using Vim inside the Windows Subsystem for Linux. The windows command prompt has a bug which renders the background color incorrectly. The fix is set t_ut=. Rather than applying this fix in all

Show Detail

Windows Subsystem for Linux DISPLAY variable setup

I'm experimenting with Windows Subsystem for Linux and am trying to create python plots using Matplotlib. But i get the following error RuntimeError: Invalid DISPLAY variable echo DISPLAY shows n...

Show Detail

CLI tools when using bash on windows with subsystem for Linux

I have installed NPM for Windows, Git for Windows and bunch for global NPM packages that I can use from command line. When I use bash shell from Windows Subsystem for Linux, do I have to install a...

Show Detail

Matplotlib does not show up on ubuntu windows subsystem

I have installed matplotlib on ubuntu windows subsystem and run this simple code: import matplotlib import matplotlib.pyplot as plt import numpy as np plt.plot([1, 2, 3, 4]) plt.show() But it jus...

Show Detail

linux subsystem on windows, how to set working directory to a folder on windows?

I am trying to import a file on windows 11 to a linux subsystem (Ubuntu 22.04.1) while it is connected to docker. I am new to this so I am sorry if I am making obvious mistakes. To my understanding...

Show Detail

Using matplotlib to create a histogram on Windows Subsystem for Linux Ubuntu

I am trying to create a simple histogram for a csv file named "count_backers.csv". The code that I have so far is as follows: import matplotlib.pyplot as plt # import numpy as np import plotly.plo...

Show Detail

Anaconda on Windows Subsystem for Linux

Anaconda was successfully installed using Example 1 in my Windows Subsystem for Linux (WSL). After completing the installation, I managed to run a Jupyter notebook in a browser and everything was

Show Detail

Flutter and Windows Subsystem for Linux

I have recently switched back from Ubuntu to Windows with Windows Subsystem for Linux using Ubuntu. I want to get in touch with Flutter and would like to be able to use the bash for the Flutter-com...

Show Detail