PyQT/Matplotlib in Windows Subsystem for Linux

  1. install X11 server for WSL
  2. install QT

     apt install libqtgui4
  3. setup Anaconda Python on WSL
  4. install Matplotlib

     conda install matplotlib

Matplotlib in WSL notes

Install Matplotlib for WSL using system Python

If you don’t want to use Anaconda Python for WSL, you can use Matplotlib in system Python by:

apt install python-matplotlib

Non-X11 Matplotlib use

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

Start your Python code with:

import matplotlib

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

Matplotlib errors on WSL


import matplotlib

gives error

ImportError: cannot open shared object file: No such file or directory

then consider installing X11 in Windows Subsystem for Linux.

Tags: , ,


Written by Michael Hirsch, Ph.D. //