实际情形有可能是:

tests/test_enlighten.py:: in <module>
import re, sys, signal, logging, argparse, pyautogui, subprocess
/usr/lib/python2./site-packages/pyautogui/__init__.py:: in <module>
from . import _pyautogui_x11 as platformModule
/usr/lib/python2./site-packages/pyautogui/_pyautogui_x11.py:: in
<module>
_display = Display(os.environ['DISPLAY'])
/usr/lib64/python2./UserDict.py:: in __getitem__
raise KeyError(key)
E   KeyError: 'DISPLAY'

极有可能是由于shell环境中对于图形输出的设置获取或识别失败,此类情况还有可能出现在用shell打开浏览器。一般都是`DISPLAY`云云。

在shell中的做法:

#!/bin/bash
export DISPLAY=:

在Python脚本中的做法:

#! python3
#导入os模块设置DISPLAY
import os
os.environ['DISPLAY'] = ':0'

#再导入pyautogui
import pyautogui
#其他操作

PyAutoGui 中遇到的KeyError : DISPLAY的更多相关文章

  1. bootstrap中给表格设置display之后表格宽度变小问题解决

    问题描述:bootstrap中给表格设置display之后表格宽度变小了 解决方案:给表格加上 display:table样式就可以了.

  2. css中的clear:both,display:flex;

    介绍两者一起讨论的原因: 在明天就国庆的日子里陪着程序员的只有代码,啤酒,还有音乐,然后就是灯光下默默陪伴自己的影子.好了,不矫情了. -------------------------------- ...

  3. 14、运行Django时浏览器中遇到Refused to display 'url' in a frame because it set 'X-Frame-Options' to 'deny'

    问题:Refused to display 'url' in a frame because it set 'X-Frame-Options' to 'deny' 解决办法: 只需要在 Djagno ...

  4. CSS中你知道的display的值有多少?用了多少?

    它的语法如下: display:none | inline | block | list-item | inline-block | table | inline-table | table-capt ...

  5. css 中visibility:hidden和display:none有什么区别呢

    <div style="width:100px;height:100px;background:red;visibility:hidden"></div>/ ...

  6. Thinkphp中的assign() 和 display()

    说到 $this->assign()  与 $this->display()想必用过TP框架的都不陌生,那么今天我们就来说说他们的作用及其他用法. 先说 $this->assign( ...

  7. ie、firefox、chrome中关于style="display:block" 引发的页面布局错乱的解决办法

    ie.firefox.chrome中关于style="display:block" 引发的页面布局错乱的解决办法: table中tr 添加style="display:b ...

  8. 细说CSS中的display属性

    相信大部分奋战在前端的,尤其在前端攻城的过程中,有一种越陷越深的感觉,不错,一如前端深似海,从此妹子是浮云啊,前端上手容易,深入难啊!下面我就CSS中的display属性讲下我自己所积累的,与大家共享 ...

  9. ArcGIS engine中Display类库——Display

    转自原文  ArcGIS engine中Display类库——Display Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这 ...

随机推荐

  1. ubuntu16.0.4安装mysql5.7以及设置远程访问

    1.安装mysql命令 sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysq ...

  2. MyBatis学习笔记(一)

    测试Demo的目录结构: com.luohao.config ->MyBatisCongfig.xml ->userMapper.xml com.luohao.Test ->Test ...

  3. 初识WCF1

    参照: http://blog.csdn.net/songyefei/article/details/7363296 第一篇 Hello WCF WCF(Windows Communication F ...

  4. 在datagridview中添加button按钮

    .Net的DataGridView控件中,提供了一种列的类型,叫 DataGridViewButtonColumn ,这种列类型是展示为一个 按钮,可以给button赋予相应的text,并且,此but ...

  5. MVC controller的Action获取HttpRequest

    HttpContext.ApplicationInstance.Context.Request

  6. windows 下 gdb 的安装

    在 windows 下 gcc/g++ 的安装 这篇文章中已经提到,用MinGW Installation Manager可以方便地管理 MinGW 组件,因此使用该软件安装 gdb . 打开 Min ...

  7. JQuery学习---JQuery深入学习

    属性操作 $("p").text()    $("p").html()   $(":checkbox").val() $(".te ...

  8. Mysql常用语句与函数(待续)

    -- 查询语句select class from stu_info where sid=1000000102;select * from stu_info t where t.age=88; -- t ...

  9. 沉淀再出发:Bean,JavaBean,POJO,VO,PO,EJB等名词的异同

    沉淀再出发:Bean,JavaBean,POJO,VO,PO,EJB等名词的异同 一.前言 想必大家都有这样的困惑,接触的东西越多却越来越混乱了,这个时候就要进行对比和深入的探讨了,抓住每一个概念背后 ...

  10. iOS开发之iOS界面UI

    1.UILabel NSString *str = @"字符串大小"; UIFont *font = [UIFont fontWithName:@"Arial" ...