User images not accessible after packaging with PyInstaller
drandreaskrueger opened this issue · comments
Together with PyInstaller, the
@Gooey (image_dir='images')
directive is resulting in
IOError: Unable to find the user supplied directory images
I have tried many many things, but I haven't understood PyInstaller enough to solve it properly.
The binary in releases is actually working, but I hacked around the problem. However, my hack is 'dirty'. I am looking for a cleaner solution.
Please see these explanations: https://github.com/drandreaskrueger/unchunk/blob/master/pyinstaller.md#images-missing
Thanks a lot!
This is functionality that's currently not handled well in Gooey. Your current work around is a decent one for the time being.
The main issue is that, while you can easily include an extra custom image directory while packaging (by supplying a new Tree option to the EXE
section in your build.spec, Gooey still won't know how to actually reach those files when it's being run as a bundled application due to path mismatches.
You can read up on MEIPASS in the PyInstaller docs for more background. However, the short versions is that Gooey is reading from a totally different location after being packaged. This, as you've seen, breaks the relative path to your images directory.
When I get some free time, I'll investigate this more. The fix should be a simple one.
Thanks a lot. And for the reading suggestion. A complex beast, that PyInstaller...
When I get some free time
Take your time - I have my workaround solution.
And thanks for calling it 'decent' g.
The fix should be a simple one.
Yes.
This
gooey_images = Tree(os.path.join(gooey_root, 'images'), prefix = 'gooey/images')
does work.
So the solution might probably involve to simply choose the right
my_images = Tree(os.path.join(os.getcwd(), 'images'), prefix = '????????')
?
And perhaps in combination with an absolute path either in my
@Gooey (image_dir='images')
or in your patch_images(new_image_dir).
But whatever I tried, I could not find the right combination yet.
Enjoy your Sunday :-)
The bug seems to be still active. I have a solution to propose. You must add the link to the icons in build.spec
and dont use the image_dir
argument in your script.
datas=[
('.\\images\\config_icon.png', '.\\gooey\\images'),
('.\\images\\program_icon.png', '.\\gooey\\images')
],
I hope this help.