More than 5 years have passed since last update.
$DISPLAYが未定義でmatplotlibがコケる問題を再発させない方法
52
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
めでたしめでたし
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
