jithurjacob / Windows-10-Toast-Notifications

Python library to display Windows 10 Toast Notifications
MIT License
970 stars 168 forks source link

It doesnt work when exporting for exe using pyinstaller :( #25

Closed marcelo-franceschini closed 6 years ago

marcelo-franceschini commented 6 years ago

Or am I doing it wrong?

jithurjacob commented 6 years ago

Can you please provide the error logs?

marcelo-franceschini commented 6 years ago

https://pastebin.com/BhadDEi9

marcelo-franceschini commented 6 years ago

Any changes?

jithurjacob commented 6 years ago

I'm yet to try your steps. Will update you soon.

beeedy commented 6 years ago

Has anyone had luck wrapping this into an exe with pyinstaller?

BroderickCarlin commented 6 years ago

Just built a .exe with pyinstaller with a project that utilized this package and had no issues building or running the executable. I will post my system info below but suggest the OP post more info and/or possibly their project as it may be a configuration issue. Otherwise this seems like a non-issue

System Info:

marcelo-franceschini commented 6 years ago

still not working here.

https://pastebin.com/RpN0U4DA Python 3.6.3 PyInstaller 3.3

BroderickCarlin commented 6 years ago

@maguila93 your issues seem to be related to a configuration issue and not necessarily an issue with this library. If you may, lets do an experiment to figure out of this is the case or not. Create a single python script in a new and empty folder that contains the following code:

from win10toast import ToastNotifier

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

Run the above script in the typical fashion: python test_script.py

and verify that the popup shows as expected. Assuming the script works as expected lets try and built it into an EXE with pyinstaller: pyinstaller test_script.py

If you get any errors from this let us know, otherwise if this works and your EXE runs we know it is an issue with your previous project and not in this package itself. If the EXE builds but does not show a popup attempt to run the EXE from a cmd prompt and share the error message

marcelo-franceschini commented 6 years ago

@BroderickCarlin I did exactly what you said and I got a new error :(

https://imgur.com/a/mmZZ3

BroderickCarlin commented 6 years ago

@maguila93 run the script from a cmd window to see what error is stopping the EXE from running.

marcelo-franceschini commented 6 years ago

@BroderickCarlin can you please try to complite to exe, test it and upload it? https://pastebin.com/FacJFVpQ thanks

BroderickCarlin commented 6 years ago

@maguila93 I think it would be better if you chased down whatever problem you are having and find the root cause of your issue. I am not going to do this for you, sorry. I suggest getting that toy script I posed above to build/run as I believe when you get this working you will figure out the reason as to why your other project(s) are not building. The error logs posted seem to indicate more issues than just this package.

@jithurjacob At this point I think this issue can be closed as it appears to be an issue in @maguila93 's environment or project architecture and not actually an issue with this package.

jithurjacob commented 6 years ago

@BroderickCarlin thanks a lot for the following this up

7ko commented 6 years ago

I can confirm it doesn't work when running pyinstaller on win7. Resulting exe doesn't show notifications niether on win7 nor on win8.1.

When I run pyinstaller on win8.1 it's fine with Windows-10-Toast-Notifications, but then exe wouldn't start on win7, so not an option for me.

BroderickCarlin commented 6 years ago

@7ko Do you have your project wrapped in an anaconda environment? Give that a shot and report back

npjibin commented 6 years ago

I am getting below error while i click on the exe which have below code

Code : from win10toast import ToastNotifier toaster = ToastNotifier() toaster.show_toast("Test","Message!",icon_path=None,duration=10)

Error : C:\Users\jnp>C:\Users\jnp\dist\test.exe

Traceback (most recent call last): File "test.py", line 9, 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 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 [14956] Failed to execute script test

7ko commented 6 years ago

@BroderickCarlin hi sorry for the late reply I was on vacation and then it took me some time to figure out the Anaconda thing.

I have a little correction on my previous statement on the problem. The toast does not show after using pyinstaller with neither win8.1 nor win7 environment.

However, the was an exception I failed to notice because I used 'console=False' clause.

Exception in thread Thread-1: Traceback (most recent call last): File "c:\python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "c:\python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "c:\python36\lib\site-packages\win10toast__init.py", line 93, in _show_toast icon_path = resource_filename(Requirement.parse("win10toast"), "win10toast/data/python.ico") File "c:\python36\lib\site-packages\pkg_resources__init__.py", line 1243, in resource_filename return get_provider(package_or_requirement).get_resource_filename( File "c:\python36\lib\site-packages\pkg_resources__init__.py", line 451, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] File "c:\python36\lib\site-packages\pkg_resources\init.py", line 999, in require needed = self.resolve(parse_requirements(requirements)) File "c:\python36\lib\site-packages\pkg_resources\init__.py", line 885, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'win10toast' distribution was not found and is required by the application

From this I suspected that the problem is with the icon. No icon_path parameter to show_toast() or None has win10toast module reaching to win10toast/data/python.ico resource which appears to be missing in case of pyinstaller application.

Adding a valid icon (i.g. icon_path='SINEWAVE.ICO') solved the problem nicely.

BroderickCarlin commented 6 years ago

@7ko , thanks for the follow up! I hadn't even considered that this may be related to the icon file but I am glad that resolved all the issues we have been seeing. The simple solution here would be just to try and silently handle the situation where we can not find the icon file.

babygame0ver commented 5 years ago

It is not working after providing it a valid Icon path

capture

babygame0ver commented 5 years ago

I have used this command

pyinstaller -F "D:\battery-status-notification\batwithnotify.py" -i "C:\Python27\python.exe"

ghost commented 5 years ago

hello , i'm also facing the same issue, May i know what exactly the problem is!

470mr0f1 commented 5 years ago

Any news?

marcelo-franceschini commented 5 years ago

@470mr0f1 try installing https://www.microsoft.com/en-US/download/details.aspx?id=50410

470mr0f1 commented 5 years ago

thanks, I solved it providing an icon path with a custom icon.

It is also working providing an invalid path. You get an error printed but the pop-up is still working without an icon.

abuzze commented 4 years ago

It is not working after providing it a valid Icon path

capture

I had the same issue and replacing icon_path=NONE', with icon_path='SINEWAVE.ICO', fixed it. But I had more than one notification and this must be done for all toast. Took me a few minutes, to find this mistake.

rezay295 commented 4 years ago

pkg_resources.DistributionNotFound: The 'win10toast' distribution was not found and is required by the application [19164] Failed to execute script login

chrisSCM commented 4 years ago

Adding a valid icon (i.g. icon_path='SINEWAVE.ICO') solved the problem nicely.

EDIT: I was looking for the place, where the icon path has to be provided. I am already setting it, but to "None" like this:

        from win10toast import ToastNotifier
        toaster = ToastNotifier()
        toaster.show_toast("Konfiguration",
                           f"Problem mit den Einstellungen:\n\n{e}",
                           icon_path=None,
                           duration=10)

Changing the icon_path to '' instead of None fixed the problem.

        from win10toast import ToastNotifier
        toaster = ToastNotifier()
        toaster.show_toast("Konfiguration",
                           f"Problem mit den Einstellungen:\n\n{e}",
                           icon_path='',
                           duration=10)
RedTeaDev commented 4 years ago

uhh ignore it

smv1999 commented 3 years ago

Adding a valid icon (i.g. icon_path='SINEWAVE.ICO') solved the problem nicely.

EDIT: I was looking for the place, where the icon path has to be provided. I am already setting it, but to "None" like this:

        from win10toast import ToastNotifier
        toaster = ToastNotifier()
        toaster.show_toast("Konfiguration",
                           f"Problem mit den Einstellungen:\n\n{e}",
                           icon_path=None,
                           duration=10)

Changing the icon_path to '' instead of None fixed the problem.

        from win10toast import ToastNotifier
        toaster = ToastNotifier()
        toaster.show_toast("Konfiguration",
                           f"Problem mit den Einstellungen:\n\n{e}",
                           icon_path='',
                           duration=10)

This fixed the error for me!

mrsalesforce commented 3 years ago

Yeah just do not leave out icon_path in the attributes and also do not give value as None. Either give any icon path or just give blank string as ''.