ShangtongZhang / reinforcement-learning-an-introduction

Python Implementation of Reinforcement Learning: An Introduction
MIT License
13.54k stars 4.82k forks source link

something wrong in matplotlib #139

Open FYYFU opened 3 years ago

FYYFU commented 3 years ago

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

rohitdavas commented 3 years ago

Can you please post full traceback .

FYYFU commented 3 years ago

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