我可以在 spyder (python 3.9) 上运行此代码,但是当我在 Linux 上运行相同的代码时,它给出
键错误:‘DISPLAY’
Python 代码
import pywhatkit
sender = "[email protected]"
password = "password"
sub = "Subject of the mail"
message = "This is a test email"
receiver = "[email protected]"
pywhatkit.send_mail((sender), (password), (sub), (message), (receiver))
Linux 上的输出
Traceback (most recent call last):
File "mail.py", line 1, in <module>
import pywhatkit
File "/usr/local/lib/python3.8/dist-packages/pywhatkit/__init__.py", line 7, in <module>
from pywhatkit.main import print_sleep_time, check_window, sendwhatmsg, sendwhatmsg_to_group, sendwhatmsg_instantly, info, playonyt, search
File "/usr/local/lib/python3.8/dist-packages/pywhatkit/main.py", line 3, in <module>
import pyautogui as pg
File "/usr/local/lib/python3.8/dist-packages/pyautogui/__init__.py", line 241, in <module>
import mouseinfo
File "/usr/local/lib/python3.8/dist-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/lib/python3.8/os.py", line 673, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'