Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marcelo-franceschini opened this issue Dec 13, 2017 · 30 comments
Closed

Comments

@marcelo-franceschini
Copy link

Or am I doing it wrong?

@jithurjacob
Copy link
Owner

Can you please provide the error logs?

@marcelo-franceschini
Copy link
Author

@marcelo-franceschini
Copy link
Author

Any changes?

@jithurjacob
Copy link
Owner

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

@beeedy
Copy link

beeedy commented Jan 18, 2018

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

@BroderickCarlin
Copy link
Contributor

BroderickCarlin commented Jan 29, 2018

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:

  • Windows 10 PRO, 10.0.16299 Build 16299
  • Python 3.6.3
  • Anaconda 4.4.6
  • PyInstaller 3.3.1

@marcelo-franceschini
Copy link
Author

still not working here.

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

@BroderickCarlin
Copy link
Contributor

BroderickCarlin commented Jan 30, 2018

@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
Copy link
Author

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

https://imgur.com/a/mmZZ3

@BroderickCarlin
Copy link
Contributor

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

@marcelo-franceschini
Copy link
Author

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

@BroderickCarlin
Copy link
Contributor

BroderickCarlin commented Jan 31, 2018

@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
Copy link
Owner

jithurjacob commented Feb 1, 2018

@BroderickCarlin thanks a lot for the following this up

@7ko
Copy link

7ko commented May 16, 2018

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
Copy link
Contributor

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

@npjibin
Copy link

npjibin commented Jun 11, 2018

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
Copy link

7ko commented Jun 19, 2018

@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
Copy link
Contributor

@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
Copy link

It is not working after providing it a valid Icon path

capture

@babygame0ver
Copy link

I have used this command

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

@ghost
Copy link

ghost commented Nov 17, 2018

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

@470mr0f1
Copy link

Any news?

@marcelo-franceschini
Copy link
Author

@470mr0f1
Copy link

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
Copy link

abuzze commented Sep 21, 2019

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
Copy link

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

@chrisSCM
Copy link

chrisSCM commented Mar 24, 2020

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
Copy link

uhh ignore it

@smv1999
Copy link

smv1999 commented Dec 14, 2020

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
Copy link

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 ''.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests