Python 中的会员通知?

plyer notification in Python?

我在 python 中做了一个断水,它在 ide 中正常工作,它发出通知但是当我使用 pyinstaller 将它变成 .exe 时它应该发出通知崩溃了,谁能帮我解决这个问题?

from plyer import notification
import time
print("Welcome to Water Break")
Timer = int(input("What timer You would I like to keep?"))
print(" thank you will be reminded in",Timer,"mins")
time.sleep(Timer)
title = 'Water Break! '
message = 'it is time a for a WaterBreak'
notification.notify(title=title,
                    message=message,
                    app_icon= 'icon.ico',
                    timeout=10,
                        toast=True)

是的,因为您需要明确指定隐藏导入

--hidden-import plyer.platforms.win.notification

参见此处示例:https://github.com/beliaev-maksim/beta_build_downloader/blob/de0448ed1f9576791df51bae1e1805c0b8d53e60/electron_ui/compile_downloader_backend.cmd#L22

如果有帮助,请不要忘记投票并标记为已接受的答案