ssh 远程登录 Linux 服务器使用 matplotlib.pyplot 绘图时报错

原因:

matplotlib 在 windows 下的默认 backend 是 TkAgg;在 Linux 下的默认 backend 是 Qt5Agg。但是这两个 backend 都要求有 GUI 图形界面,所以在 Linux 服务器上运行时会报错。

另外 FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx, WxAgg这几个backend都要求有GUI图形界面的

解决办法:更换 backend

将 backend 更换为不需要 GUI 的 backend,比如 Agg, Cairo, PS, PDF, SVG

import matplotlib.pyplot as plt
plt.switch_backend('agg')

matplotlib 绘图报错 RuntimeError: Invalid DISPLAY variable的更多相关文章

  1. ssh调用matplotlib绘图报错RuntimeError: Invalid DISPLAY variable

    1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...

  2. [Python] RuntimeError: Invalid DISPLAY variable

    1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...

  3. 错误RuntimeError: Invalid DISPLAY variable

    原因:matplotlib的backend中的FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg这几个backend都要求有GUI图形界面的 首先查 ...

  4. pylab,matplotlib Invalid DISPLAY variable

    在cetos 服务器使用源码包,安装matplotlib, 安装成功后, import pylab as pl pl.figure(figsize=(16,8)) python 解析器报错,Inval ...

  5. 安装tesserocr的步骤和报错RuntimeError: Failed to init API, possibly an invalid tessdata path解决办法

    1,首先下载合适的tesseract-ocr的版本 2,然后安装到这一步注意要勾选这一项来安装OCR识别支持的语言包,这样OCR就可以识别多国语言,然后就可以一直点击下一步完成安装. 3,安装tess ...

  6. Jade报错:Invalid indentation,you can use tabs or spaces but not both问题

    现象:通过html生成jade文件之后,更改jade文件时,语句没什么问题的情况下,jade文件编译不通过,报错:Invalid indentation,you can use tabs or spa ...

  7. Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set.

    Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and ...

  8. mysql创建表时,设置timestamp DEFAULT NULL报错1067 - Invalid default value for 'updated_at'

    问题背景: 线上的linux服务器上的mysql服务器中导出数据库的结构.想要在本地创建一个测试版本 导出后再本地mysql上运行却报错   1067 - Invalid default value ...

  9. 数据库查询语句报错-ORA-00911: invalid character

    数据库查询语句报错-ORA-00911: invalid character 根据自己经验总结下: 1.都是分号惹的祸,有时候sql语句后面有分好导致这种错误 2.还有一种是从别处copy过来的sql ...

随机推荐

  1. iOS如何转换十三位的时间戳

    //将十三位的时间戳转换为日期 - (NSString *)getDate:(NSString *)jsonDate { //jsonDate类似这种/Date(1447659630000)/ NSA ...

  2. Win7+ 电脑 休眠 自动唤醒

    https://jingyan.baidu.com/article/3ea51489d905df52e71bba6b.html

  3. java面试题复习(八)

    71.如何通过反射创建对象? 方法1:通过类对象调用newInstance()方法,例如:String.class.newInstance()  方法2:通过类对象的getConstructor()或 ...

  4. python学习笔记---环境的安装,pip命令,数据类型,运算

    1.进入python环境: python 2:py -2 python 3:py -3 2.退出python环境 exit()/quit()/ctrl+z+enter ctrl+z+enter没有尝试 ...

  5. 2018-2019-2 网络对抗技术 20165304 Exp6 信息搜集与漏洞扫描

    2018-2019-2 网络对抗技术 20165304 Exp6 信息搜集与漏洞扫描 原理与实践说明 1.实践原理 信息搜集:渗透测试中首先要做的重要事项之一,搜集关于目标机器的一切信息 间接收集 D ...

  6. TinkPHP框架学习-04命名空间

    1-----命名空间 2-----调用其他控制器的方法 3-----U()函数 一命名空间 ①看做是虚拟目录 --ThinkPHP/Library 初始命名空间 --在Library文件夹下的所有文件 ...

  7. Java就业班day09_xml&tomcat

    Xml & Tomcat Xml eXtendsible markup language 可扩展的标记语言 XML 有什么用? 可以用来保存数据 可以用来做配置文件 数据传输载体 定义xml ...

  8. 【396】python 递归练习题(COMP9021)

    Merging two strings into a third one Say that two strings s1 and s2 can be merged into a third strin ...

  9. es 服务器搭建

    安装jdk,原系统安装的openjava 参考https://www.cnblogs.com/Dylansuns/p/6974272.html注意配置/etc/profile 时,要注意自己安装的是哪 ...

  10. Bootstrap中的data-toggle,data-target

    data-toggle指以什么事件触发常用的如collapse,modal,popover,tooltips等:data-target指事件的目标, 一起使用就是代表data-target所指的元素以 ...