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. C# 面试知识点网络文档整理

    一 C# .NET技术 1.ASP.NET MVC如何控制权限? 2.C#.NET中的CTS.CLS和CLR? 3.什么是多线程,如何创建和如何使用?请写一个多线程单例模式? 4.什么是单例模式? 5 ...

  2. javascript 数组的简单应用

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. rsync:基本命令和用法

    以下是rsync系列篇: 1.rsync(一):基本命令和用法 2.rsync(二):inotify+rsync详细说明和sersync 3.rsync算法原理和工作流程分析 4.rsync技术报告( ...

  4. py库:numpy

    http://www.numpy.org/ numpy官网 http://cwiki.apachecn.org/pages/viewpage.action?pageId=10030181 scikit ...

  5. Linux 文件目录管理命令

    1.touch 用于设置空白文件或设置文件时间 touch命令参数及作用 参 数                                                             ...

  6. python-day12 MySQL、sqlalchemy

    @第一节上周回顾没看 @博客day11 https://www.cnblogs.com/alex3714/articles/5950372.html @InnoDB,是MySQL的数据库引擎之一 @S ...

  7. sublime编译javaScript脚本

    处理步骤: 1. 首先到 nodejs.org 下载 Node.js 安装包并安装.2. 打开 Sublime Text 3 编辑器.选择菜单 Tools --> Build System -- ...

  8. Vim 简明教程【转载】

    简明 Vim 练级攻略 第一级 – 存活 安装 vim 启动 vim 什么也别干!请先阅读 当你安装好一个编辑器后,你一定会想在其中输入点什么东西,然后看看这个编辑器是什么样子.但vim不是这样的,请 ...

  9. POIUtils 导出 poi Test 100w 600w 条数据

    依赖: <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-l ...

  10. maven source 1.3 中不支持泛型 解决办法

    maven打包时始终出现以下提示:1.-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)List<User> userList= new ArrayL ...