Matplotlib in Windows Subsystem for Linux

  1. install X11 server for WSL
  2. setup Anaconda Python on WSL
  3. install Matplotlib
    conda install matplotlib
    

Notes

Non-X11 Matplotlib use

You can make plots using .savefig() without X11 installed in WSL.

Start your Python code with:

import matplotlib
matplotlib.use('agg')
print(matplotlib.get_backend())

you should see agg printed. This will allow writing figures to disk, but will disallow displaying them on screen.

Matplotlib errors on WSL

if

import matplotlib

gives error

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

then consider installing X11 in Windows Subsystem for Linux.

Tags: , ,

Categories:

Written by Michael Hirsch, Ph.D. //

Comments