WSLでXサーバ

WSLでXサーバにトライしました。

Xming

Xming X Server for Windows - Official Website

メジャーなXサーバです。使用形態によっては有償らしいので、Sourceforgeパブリックドメインとして配布されている6.9.0.31をダウンロードします。ダウンロードサイトは以下。

Xming X Server for Windows download | SourceForge.net

xmingのセットアップ後は、WSL側での設定変更です。下記を参考に進めます。

www.atmarkit.co.jp

WSLでmatplotlibやgnuplotでプロットができない - Qiita

環境変数のDISPLAYを設定します。.bashrcに記載します。

export DISPLAY=:0.0

xサーバの基本アプリをインストールします。インストールしたらxeyesを起動します。windows側のxmingの起動を忘れず。

$ sudo apt install x11-apps
$ xeyes

なんじゃこいつは(笑)

f:id:matsuo_san:20200215203943p:plain

gnuplotも確認します。インストール。

$ sudo apt install gnuplot
$ gnuplot
$ plot sin(x)

f:id:matsuo_san:20200215204053p:plain

ばっちり。

追記(2020/03/01)

matplotlibを使おうとすると、

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

のエラーが。

$ sudo apt install python3-tk

にて解決しました。

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. を直す - Qiita