错误RuntimeError: Invalid DISPLAY variable
原因:matplotlib的backend中的FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg这几个backend都要求有GUI图形界面的
首先查看了一下本机matplotlib的默认backend为:
user@home:/opt/user$ python
Python 3.6. |Anaconda custom (-bit)| (default, Oct , ::)
[GCC 7.2.] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.get_backend()
'Qt5Agg'
但是因为我上面没有GUI,所以会报错:RuntimeError: Invalid DISPLAY variable
为了解决这个问题,在代码中添加上:
plt.switch_backend('agg')
解决方法:指定不需要GUI的backend(Agg, Cairo, PS, PDF or SVG)
然后问题就解决了
错误RuntimeError: Invalid DISPLAY variable的更多相关文章
- [Python] RuntimeError: Invalid DISPLAY variable
1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...
- ssh调用matplotlib绘图报错RuntimeError: Invalid DISPLAY variable
1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...
- matplotlib 绘图报错 RuntimeError: Invalid DISPLAY variable
ssh 远程登录 Linux 服务器使用 matplotlib.pyplot 绘图时报错 原因: matplotlib 在 windows 下的默认 backend 是 TkAgg:在 Linux 下 ...
- pylab,matplotlib Invalid DISPLAY variable
在cetos 服务器使用源码包,安装matplotlib, 安装成功后, import pylab as pl pl.figure(figsize=(16,8)) python 解析器报错,Inval ...
- 图形化界面安装oracle报错Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.
问题描述: 在Linux + oracle 安装时,采有root 帐号登录x-windows 界面,然后 $su oracle 登录录安装Oracle 报以下错误: >>> Coul ...
- php foreach 语法的遍历来源数组如果不是一个有效数组php会出现错误警告 Invalid argument supplied for foreach()
在php中,foreach语法的遍历来源数组如果不是一个有效数组,php会出现错误警告 Invalid argument supplied for foreach() ,但是很多时候这个数组是取自某些 ...
- 发生了Post错误:错误代码40005,微信返回错误信息:invalid file type
给客户部署 PxxCms, 使用群发功能发送图文的的时候提示: 发生了Post错误:错误代码40005,微信返回错误信息:invalid file type, 没学过php伤不起 ... Google ...
- class java.awt.HeadlessException : No X11 DISPLAY variable was set, but this program performed an operation which requires it.
今天上午打印回单功能发布到测试环境,报了: class java.awt.HeadlessException : No X11 DISPLAY variable was set, but this p ...
- 错误:Invalid action class configuration that references an unknown class named [XXX]的解决
问题: 用http的方式直接调用类,执行完毕后报错误信息Invalid action class configuration that references an unknown class name ...
随机推荐
- cron和crontab命令详解 crontab 每分钟、每小时、每天、每周、每月、每年定时执行 crontab每5分钟执行一次
cron机制 cron可以让系统在指定的时间,去执行某个指定的工作,我们可以使用crontab指令来管理cron机制 crontab参数 -u:这个参数可以让我们去编辑其他 ...
- js-dot.js
//小结// toExponential 保留小数点( 0-20 bit ) document.writeln(Math.PI.toExponential(0)); //3e+0 document.w ...
- 二进制安装 kubernetes 1.12(五) - 运行测试实例
检查集群状态 # 在 master 上 kubectl get node kubectl get cs 注册登录阿里云容器仓库 因国内无法获得 google 的 pause-amd64 镜像,我这里使 ...
- 洛谷P2868 [USACO07DEC]观光奶牛Sightseeing Cows(01分数规划)
题意 题目链接 Sol 复习一下01分数规划 设\(a_i\)为点权,\(b_i\)为边权,我们要最大化\(\sum \frac{a_i}{b_i}\).可以二分一个答案\(k\),我们需要检查\(\ ...
- Ambari架构源码解析
1. Ambari介绍 Apache Ambari是一种基于Web的工具,支持Apache Hadoop集群的供应.管理和监控.Ambari已支持大多数Hadoop组件,包括HDFS.MapReduc ...
- Loadrunner 脚本优化-事务函数简介
脚本优化-事务函数简介 by:授客 QQ:1033553122 1.事务的开始和结束名称需要相同 lr_start_transaction(“transaction_name”); …//事务处理 l ...
- Django 配置MySQL数据库
在settings.py中配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # 数据库引擎 'NAME': 'my ...
- python Django 文件下载示例
from django.http import StreamingHttpResponse#文件流 def big_file_download(request): # do something... ...
- HttpHandler实现网页图片防盗链
using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary ...
- Linux下进程的创建过程分析(_do_fork do_fork详解)--Linux进程的管理与调度(八)
Unix标准的复制进程的系统调用时fork(即分叉),但是Linux,BSD等操作系统并不止实现这一个,确切的说linux实现了三个,fork,vfork,clone(确切说vfork创造出来的是轻量 ...