LoginSignup
51
47

More than 5 years have passed since last update.

$DISPLAYが未定義でmatplotlibがコケる問題を再発させない方法

Last updated at Posted at 2014-03-10

ssh経由でリモートログインしていてmatplotlibを使った可視化のスクリプトを実行したりすると、たとえGUIを出すコードではなくファイルに出力するコードでも _tkinter.TclError: no display name and no $DISPLAY environment variable と怒られてしまう。

で、その直接的な解決方法はもちろん env DISPLAY=:0 python ... でよいのだけども、まあ人間はうっかり付け忘れてがっかりする生き物なので恒久的に再発防止をしたい。

このエラーの根本的な原因はmatplotlibのデフォルトバックエンドがTkAggになっているせい。というわけで /etc/matplotlibrc で以下のように変更すれば良い。

- backend      : TkAgg
+ backend      : Agg

めでたしめでたし

51
47
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
51
47