如何修复在jupyter笔记本上安装pyautogui时的错误?

2024-04-24 22:37:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用以下行使用anaconda提示符安装PyAutoGui:

pip -m install pyautogui

安装似乎成功,但在google上导入库pyautogui时 colab,我得到以下错误:

KeyError Traceback (most recent call last) in () ----> 1 import pyautogui

2 frames /usr/lib/python3.7/os.py in getitem(self, key) 679 except KeyError: 680 # raise KeyError with the original key value --> 681 raise KeyError(key) from None 682 return self.decodevalue(value) 683

KeyError: 'DISPLAY'

我能做些什么来解决这个问题


Tags: installpipkeyinselfvaluegoogleanaconda
1条回答
网友
1楼 · 发布于 2024-04-24 22:37:39

我发现了一个有趣的材料:

https://tylergarrett.com/code/2018/11/using-pyautogui-with-colaboratory-not-possible-today/

简而言之,作者说

"using Pyautogui with Colaboratory is not currently possible because the code isn’t running with an active display, rather it’s more of a web based place to run python".

"GUI automation should be accomplished on a local machine and Colaboratory will not be a place for GUI automation, because it is an online colaboration tool."

https://colab.research.google.com/drive/1UtSMGU5UaGowWA9mM3Kq7QR-LBzbbFDE?usp=sharing

相关问题 更多 >