matplotlib 第二次执行报错在 django web服务中
2017-09-14 18:25
190 查看
报错内容如下:
Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.del of < Tkinter.PhotoImage instance at 0x7f347192b5a8>> ignored
解决方法:最代码最顶层加:
要在 pylab 和 matplotlib.pyplot 之前,否则无效。
这里有一个容易让人忽视的地方,因为有些python 库 也包含了pylab 或 matplotlib.pyplot, 如果上述代码未加在他们之前,则会无效,不熟悉的话很难找到原因,所以最保险的是加代码文件的在最顶层。
Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.del of < Tkinter.PhotoImage instance at 0x7f347192b5a8>> ignored
解决方法:最代码最顶层加:
import matplotlib matplotlib.use('Agg')
要在 pylab 和 matplotlib.pyplot 之前,否则无效。
这里有一个容易让人忽视的地方,因为有些python 库 也包含了pylab 或 matplotlib.pyplot, 如果上述代码未加在他们之前,则会无效,不熟悉的话很难找到原因,所以最保险的是加代码文件的在最顶层。
相关文章推荐
- 在Django中输出matplotlib生成的图片方法
- mac 安装matplotlib后执行程序报错
- 如何在Django中输出matplotlib生成的图片
- python爬虫webdriver.Chrome 数据可视化简单案例matplotlib
- matplotlib 命令行执行报错
- 基于【matplotlib】【imshow】【cmap】绘制【numpy.ndarray】二维数组的“二维码”
- 【Matplotlib】图例分开显示
- 绘图: Python matplotlib核心剖析
- python matplotlib绘制图(持续更新....)
- matplotlib基础——pyplot.figure()
- python3机器学习实战ID3决策树实现+matplotlib绘制树形图
- matplotlib
- 利用matplotlib+numpy绘制多种绘图的方法实例
- Matlab的Python实现Scipy和Matplotlib简介
- matplotlib 作图基本配置
- Python中使用matPlotlib绘图-曲线图、柱状图、散列点
- Python3.5安装Matplotlib
- Windows下安装Django及WEB服务启动
- 解决python27 matplotlib 中文不显示问题
- python matplotlib绘图时图例显示问题