garden and pyinstaller don't play well, needs documenting
Versions
- Python: 3.6.1
- OS: Windows
- Kivy: 1.10.0
- Kivy installation method: pip
Description
I'm following https://kivy.org/docs/guide/packaging-windows.html to package a kivy app. It works as advertised, except when using kivy.garden. The offending import is:
from kivy.garden.filebrowser import FileBrowser
In that case when running the produced .exe, things will end in:
ModuleNotFoundError: No module named 'kivy.garden'
I suspect this is due to the unusual implementation of kivy.garden, which also causes tools like PyCharm to flag imports from kivy.garden as unresolvable.
There are several StackOverflow discussions about this, without a good solution, e.g.: https://stackoverflow.com/questions/24048350/kivy-garden-in-pyinstaller-stuck-trying-to-trace-import https://stackoverflow.com/questions/41228334/getting-pyinstaller-to-recognize-the-path-to-kivy-garden-matplotlib-modules
It would be very useful if https://kivy.org/docs/guide/packaging-windows.html would include an example of how to correctly package apps which use kivy.garden.
Doing garden install --app filebrowser as suggested by the kivy-garden README doesn't make any difference, so that's (a) not the solution, and (b) bad practice (are you supposed to check in libs/garden/xxx into your version control??).
I always install it using --kivy. E.g garden install filebrowser --kivy.
On Sun, Jul 16, 2017 at 12:47 AM, Ralf Gommers [email protected] wrote:
Doing garden install --app filebrowser as suggested by the kivy-garden README doesn't make any difference, so that's (a) not the solution, and (b) bad practice (are you supposed to check in libs/garden/xxx into your version control??).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kivy/kivy/issues/5283#issuecomment-315585323, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkW_uV07jLfWOV_8-3FAcdHaVRBXeTtks5sOZXugaJpZM4OZMoQ .
I always install it using
--kivy. E.ggarden install filebrowser --kivy.
Yes, that's what I did, that installs it in a global place. PyInstaller doesn't pick it up there, that's why I opened this issue.
The garden install --app is an attempt to work around that, but it installs the garden app inside your project source tree, which is definitely not desired.
I found it useful to copy the source in a staging folder and apply changes to it before cythonizing and/or packaging it with PyInstaller. You could copy the garden flowers from the global folder to the local one in your build script, in the same place --app installation would have.
When you use --kivy, it's installed under kivy/garden/flowername and not globally into the users settings. Then pyinstaller should catch it from where you import kivy.garden.filebrowser and automatically include. This has worked for me in the past.
Are you sure you installed it with --kivy? Also make sure you deleted the global version from the user folder just in case.
Thanks for asking again. I inspected my install locations, cleaned them and then checked where
garden install filebrowser
and
garden install filebrowser --kivy
put things. The former goes to ~/.kivy/, the latter to site-packages. So I didn't use --kivy. --kivy is also not documented on http://kivy-garden.github.io/.
So I guess the documentation could be improved in two places, https://kivy.org/docs/guide/packaging-windows.html and http://kivy-garden.github.io/
I just ran into this myself, none of the above mentioned placements of the garden seemed to help.
Have any solutions surfaced? I am just forcing the .py files to be included in COLLECT with a 'libs/garden' prefix.
In case this is helpful to the discussion here: https://github.com/pyinstaller/pyinstaller/issues/2246
The --kivy solution above works, in case it's not obvious from the above (it wasn't to me).
StackOverflow 41228334 now has this solution, added after it was cited in the Description above.
Thanks for asking again. I inspected my install locations, cleaned them and then checked where
garden install filebrowserand
garden install filebrowser --kivyput things. The former goes to
~/.kivy/, the latter tosite-packages. So I didn't use--kivy.--kivyis also not documented on http://kivy-garden.github.io/.So I guess the documentation could be improved in two places, https://kivy.org/docs/guide/packaging-windows.html and http://kivy-garden.github.io/
this fixed my issue: pyinstaller ModuleNotFoundError: No module named 'kivy.garden'
Thanks for asking again. I inspected my install locations, cleaned them and then checked where
garden install filebrowserand
garden install filebrowser --kivyput things. The former goes to
~/.kivy/, the latter tosite-packages. So I didn't use--kivy.--kivyis also not documented on http://kivy-garden.github.io/.So I guess the documentation could be improved in two places, https://kivy.org/docs/guide/packaging-windows.html and http://kivy-garden.github.io/
how about Mac, on windows it worked. on Mac No module named 'kivy.garden' with pyinstaller
Following way fixed it for me:
- garden install filebrowser --app
- added files for "libs/garden/garden.filebrowser/*:libs/garden/garden.filebrowser"