PyQT/Matplotlib in Windows Subsystem for Linux

1. Prereqs for Matplotlib GUI with WSL

  1. install Xming X11 server for WSL
  2. install QT

     apt install libqtgui4

2. Anaconda Python Matplotlib on WSL

  1. setup Anaconda Python on WSL
  2. 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:

#!/usr/bin/env python

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

if import matplotlib

gives error

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

then consider installing X11 in Windows Subsystem for Linux.

Leave a Comment