ShangtongZhang/reinforcement-learning-an-introduction

something wrong in matplotlib

FYYFU opened this issue · 2 comments

FYYFU commented

The file is in Link.
ERROR:
RuntimeError: Invalid DISPLAY variable

The code:

matplotlib.use('Agg')

might be set before code:

import matplotlib.pyplot as plt

Can you please post full traceback .

FYYFU commented

Can you please post full traceback .

Error:
gambler_problem.py:4: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

The backend was originally set to 'Qt5Agg' by the following code:
File "gambler_problem.py", line 2, in
import matplotlib.pyplot as plt
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 71, in
from matplotlib.backends import pylab_setup
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backends/init.py", line 16, in
line for line in traceback.format_stack()

matplotlib.use('Agg')
Traceback (most recent call last):
File "gambler_problem.py", line 77, in
figure_4_3()
File "gambler_problem.py", line 59, in figure_4_3
plt.figure(figsize=(10, 20))
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py", line 533, in figure
**kwargs)
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 167, in new_figure_manager_given_figure
canvas = cls.FigureCanvas(figure)
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 24, in init
super(FigureCanvasQTAgg, self).init(figure=figure)
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 234, in init
_create_qApp()
File "/home/yuf/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 125, in _create_qApp
raise RuntimeError('Invalid DISPLAY variable')
RuntimeError: Invalid DISPLAY variable