community icon indicating copy to clipboard operation
community copied to clipboard

garden and pyinstaller don't play well, needs documenting

Open rgommers opened this issue 8 years ago • 13 comments

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.

rgommers avatar Jul 16 '17 04:07 rgommers

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??).

rgommers avatar Jul 16 '17 04:07 rgommers

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 .

matham avatar Jul 16 '17 14:07 matham

I always install it using --kivy. E.g garden 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.

rgommers avatar Jul 17 '17 07:07 rgommers

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.

dessant avatar Jul 17 '17 09:07 dessant

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.

matham avatar Jul 17 '17 17:07 matham

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/

rgommers avatar Jul 18 '17 22:07 rgommers

I just ran into this myself, none of the above mentioned placements of the garden seemed to help.

frostfyre avatar Oct 26 '17 21:10 frostfyre

Have any solutions surfaced? I am just forcing the .py files to be included in COLLECT with a 'libs/garden' prefix.

raidoz avatar Oct 17 '18 18:10 raidoz

In case this is helpful to the discussion here: https://github.com/pyinstaller/pyinstaller/issues/2246

m4tt-willi4ms avatar Nov 07 '18 21:11 m4tt-willi4ms

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.

escallonia avatar Jul 08 '20 23:07 escallonia

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/

this fixed my issue: pyinstaller ModuleNotFoundError: No module named 'kivy.garden'

zaheerkzz avatar Dec 23 '22 09:12 zaheerkzz

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/

how about Mac, on windows it worked. on Mac No module named 'kivy.garden' with pyinstaller

zaheerkzz avatar Dec 30 '22 13:12 zaheerkzz

Following way fixed it for me:

  1. garden install filebrowser --app
  2. added files for "libs/garden/garden.filebrowser/*:libs/garden/garden.filebrowser"

iruriksl avatar Jun 25 '25 20:06 iruriksl