plyer
plyer copied to clipboard
Works locally but fails when packaged
Hi I was hoping I could get some help
When testing my application it runs absolutely fine, but after packaging for windows, following the steps laid out in https://kivy.org/doc/stable/guide/packaging-windows.html to build an executable, plyer features no longer work.
The application closes with a Not Implemented error - I've included logs for opening a mail client but it happens for all plyer features I am using (email, filechooser and storagepath)
Traceback (most recent call last):
File "plyer\utils.py", line 93, in _ensure_obj
ModuleNotFoundError: No module named 'plyer.platforms'
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "main.py", line 89, in <module>
....
File "Services\MailService.py", line 53, in open_blank_email
File "plyer\facades\email.py", line 52, in send
File "plyer\facades\email.py", line 58, in _send
NotImplementedError
[24156] Failed to execute script main
I'm assuming I'm missing something in the build process but I'm not sure what it could be
Hi, I was also struggling with a similar issue, using the plyer filechooser. On windows, the solution was to simply add plyer.platforms.win.filechooser in the hiddenimports in your spec file:
a = Analysis(
...
datas=[],
hiddenimports=["plyer.platforms.win.filechooser"],
hookspath=[],
...
)
You can then add all the different plyer features your app is using in the hiddenimports list.
Since I had to solve this also for MacOSX, I'm going to also throw my solution here.
from kivy.tools.packaging.pyinstaller_hooks import get_deps_all, hookspath, runtime_hooks
dependencies = get_deps_all()
dependencies['hiddenimports'] += ["plyer.platforms.macosx.filechooser"]
a = Analysis(['/path/to/your/folder/containing/examples/demo/touchtracer/main.py],
pathex=['/path/to/yout/folder/containing/testpackaging'],
cipher=block_cipher,
win_no_prefer_redirects=False,
win_private_assemblies=False,
hookspath=hookspath(),
runtime_hooks=runtime_hooks(),
**dependencies)
Hope it helps !
Any update on this? Having to manually add these dependencies is annoying, but also confusing for a first-time user.
Here's my solution in the .spec
file, so that I can build for different OSes:
import platform
hiddenimports = []
if platform.system() == "Linux":
hiddenimports = ["plyer.platforms.linux.notification"]
elif platform.system() == "Windows":
hiddenimports = ["plyer.platforms.win.notification"]
And then later, in Analysis
, I do hiddenimport=hiddenimports
.
I'd like to nominate @florian-rieder for sainthood for their post here.
Fixed our issue immediately.
pyinstaller
--hidden-import plyer.platforms.win.notification
it works fine for me
@ViCrack Thank you so much! I was wondering what I was doing wrong until I found your comment.