12
8

More than 5 years have passed since last update.

サーバ上でmatplotlibを使うときのノート

Last updated at Posted at 2016-11-21

matplotlibを使ってサーバ側で作図する(savefig()など)場合、

Traceback 
...
RuntimeError: Invalid DISPLAY variable

などと怒られる場合がある。
これは、表示先のDISPLAYが設定されていないことに原因しているらしい。
解決方法1は良く見るけど、それでもダメだったときのノート。

解決方法1

import matplotlib
matplotlib('Agg')
import matplotlib.pyplot as pet

解決方法2

import matplotlib.pyplot as plt
plt.switch_backend('agg')
12
8
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
12
8