Skip to content
Advertisement

pyinstaller does not support importing kivy screen with exec

I have a kivymd app designed using the lazy loading method (all the screens and their kv files are placed in different folders so that they can be called when the user needs them using exec and eval, something similar to these projects kitchensink and kivy-lazy-loading-template). that works very well in pycharm.

folders diagram:

enter image description here

I tried to get windows output using pyinstaller but pyinstaller only checks the main and manager files (imported directly into main) and does not detect the libraries imported in screen modules when the exe file is executed and returns an error.

I tried them to datas in spec. I add them but it doesn’t work and I think I should add them to hiddenimports in .spec or directly by –hidden-import but I don’t know how to address them, I can’t do anything, please help. Thank you so much

Advertisement

Answer

I tried different ways to include the screen modules to analyze the imported libraries in the .spec file. But I realized that this is not the right way and I have to manually write the libraries in hiddenimports in .spec, like this:

a = Analysis(['main.py'],
             pathex=[path],
             binaries=[],
             datas=[],
             hiddenimports=['plyer','plyer.platforms.win.uniqueid', 'kivymd_extensions.akivymd.uix.spinners', 'pandas', 'kivymd.uix.menu', 'kivymd.uix.datatables', 'kivymd.effects.stiffscroll', 'kivymd.uix.picker', 'kivymd_extensions.akivymd.uix.behaviors.addwidget', 'pytse_client', 'yfinance', 'kivy.garden.matplotlib.backend_kivy', 'mplcursors', 'persiantools.jdatetime'],
             hookspath=[kivymd_hooks_path],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

P.S: Actually, I just imported any library that gave an error when running the exe file into hiddenimports.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement