2

The win10toast distribution was not found is displayed while i execute a python exe with toastnotification

from win10toast import ToastNotifier
toaster = ToastNotifier()
toaster.show_toast("Hello World!!!",
              "Python is 10 seconds awsm!",
              icon_path="custom.ico",
              duration=10)
toaster.show_toast("Hello World!!!",
             "Python is awesome by default!")

Screenshot

JNP
  • 53
  • 2
  • 5
  • Try installing win10toast. If it is installed, make sure that the Python search paths are correct. Also, please provide relevant information, such as the exact error message, directly in your question, instead of an attached screenshot. – Roland Weber Jun 08 '18 at 10:53
  • Traceback (most recent call last): File "delete.py", line 16, in File "site-packages\win10toast\__init__.py", line 127, in show_toast File "site-packages\win10toast\__init__.py", line 93, in _show_toast File "site-packages\pkg_resources\__init__.py", line 1225, in resource_filename File "site-packages\pkg_resources\__init__.py", line 436, in get_provider File "site-packages\pkg_resources\__init__.py", line 984, in require – JNP Jun 08 '18 at 12:57
  • File "site-packages\pkg_resources\__init__.py", line 870, in resolve pkg_resources.DistributionNotFound: The 'win10toast' distribution was not found and is required by the application [10128] Failed to execute script delete – JNP Jun 08 '18 at 12:57

4 Answers4

6

I fixed this by switching to plyer library. Initially, it had a similar issue but adding platform-specific import helped:

import plyer.platforms.win.notification
from plyer import notification

notification.notify("Title", "Body")

Reference: https://github.com/kivy/plyer/issues/485

Desprit
  • 707
  • 2
  • 11
  • 24
1

Me to faced the same problem, I have imported six,appdir and packaging.requirements in my code and converted to exe using cx_Freeze now it is working for me

from win10toast import ToastNotifier
import six
import appdirs
import packaging.requirements

toaster = ToastNotifier()
toaster.show_toast(
    "Testing pyinstaller",
    "Trying to find root cause",
    duration=10, icon_path="python.ico")

Note: we can also use this packages as hidden_import in Pyinstaller but i had not yet tested yet in pyinstaller

Dhayalan S
  • 31
  • 3
1

You didn't specify the icon_path argument in the second toaster. In my case, I solved this issue providing a valid icon_path. If this doesn't work, try icon_path=''.

Juan SB
  • 21
  • 1
1

I faced the same issue, but with win10toast_click module.

I traced the following exception's call stack:

Traceback (most recent call last):
  File "main.py", line 123, in <module>
  File "main.py", line 116, in main
  File "main.py", line 101, in check_query
  File "main.py", line 84, in notify
  File "win10toast_click\__init__.py", line 162, in show_toast
  File "win10toast_click\__init__.py", line 127, in _show_toast
  File "pkg_resources\__init__.py", line 1130, in resource_filename
  File "pkg_resources\__init__.py", line 342, in get_provider
  File "pkg_resources\__init__.py", line 886, in require
  File "pkg_resources\__init__.py", line 772, in resolve
pkg_resources.DistributionNotFound: The 'win10toast_click' distribution was not found and is required by the application

And I found out that in file win10toast_click\__init__.py, line 127, in _show_toast function, it's failing to retrieve the icon or something (resource_filename is failing at the 'else' clause):

        # icon
        if icon_path is not None:
            icon_path = path.realpath(icon_path)
        else:
            icon_path =  resource_filename(Requirement.parse("win10toast_click"), "win10toast_click/icon/notification.ico")
        icon_flags = LR_LOADFROMFILE | LR_DEFAULTSIZE

So what I did is to copy the icon file from that path, and paste it into my project's main folder, then I specified the icon_path to that new path when calling the show_toast method, like this: toaster.show_toast(title, msg, icon_path='notification.ico')

On my machine, the icon's original path is: C:\Users\<USER>\AppData\Local\Programs\Python\Python39\Lib\site-packages\win10toast_click\icon\notification.ico

Elyasaf755
  • 2,239
  • 18
  • 24