【发布时间】:2016-04-20 11:10:25
【问题描述】:
我正在尝试使用 cron 运行 python 脚本。该脚本从命令行运行没有问题,但从 cron 运行时 matplotlib 出现问题。错误如下。
Traceback(最近一次调用最后一次):
文件“/home/ubuntu/python/spread.py”,第 154 行,在 plot_spread(lat, lon, vals, mean, maxs, mins, stdp, stdm, ens_members)
文件“/home/ubuntu/python/spread.py”,第 81 行,在 plot_spread plt.fill_between(x, maxs, stdp, color='r', alpha=0.2)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第 2785 行,在 fill_between ax = gca()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第 928 行,在 gca 返回 gcf().gca(**kwargs)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第 578 行,在 gcf 返回图()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第527行,如图 **kwargs)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第 46 行,在 new_figure_manager return new_figure_manager_given_figure(num, thisFig)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第 53 行,在 new_figure_manager_given_figure canvas = FigureCanvasQTAgg(图)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第 76 行,在 初始化 FigureCanvasQT.init(self, figure)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4.py”,第 68 行,在 初始化 _create_qApp()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt5.py”,第 138 行,在 _create_qApp raise RuntimeError('无效的 DISPLAY 变量')
RuntimeError: 无效的 DISPLAY 变量
【问题讨论】:
-
完美!解决了这个问题。谢谢
标签: python matplotlib cron